mirror of
https://github.com/mitb-archive/filebot
synced 2024-11-16 22:35:04 -05:00
* replace multiple replacement pairs
This commit is contained in:
parent
878f311cae
commit
56d1892e24
@ -168,6 +168,22 @@ String.metaClass.transliterate = { transformIdentifier -> com.ibm.icu.text.Trans
|
|||||||
String.metaClass.ascii = { fallback = ' ' -> delegate.transliterate("Any-Latin;Latin-ASCII;[:Diacritic:]remove").replaceAll("[^\\p{ASCII}]+", fallback) }
|
String.metaClass.ascii = { fallback = ' ' -> delegate.transliterate("Any-Latin;Latin-ASCII;[:Diacritic:]remove").replaceAll("[^\\p{ASCII}]+", fallback) }
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replace multiple replacement pairs
|
||||||
|
*
|
||||||
|
* e.g. replace('ä', 'ae', 'ö', 'oe', 'ü', 'ue')
|
||||||
|
*/
|
||||||
|
String.metaClass.replace = { String... tr ->
|
||||||
|
String s = delegate;
|
||||||
|
for (int i = 0; i < tr.length-1; i+=2) {
|
||||||
|
CharSequence t = tr[i]
|
||||||
|
CharSequence r = tr[i+1]
|
||||||
|
s = s.replace(t, r)
|
||||||
|
}
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* General helpers and utilities
|
* General helpers and utilities
|
||||||
|
Loading…
Reference in New Issue
Block a user