, replace , , Oracle (Java 8):
public String replace(CharSequence target, CharSequence replacement) {
return Pattern.compile(target.toString(), Pattern.LITERAL).matcher(
this).replaceAll(Matcher.quoteReplacement(replacement.toString()));
}
... , - , , (), .
, 22 , , ([âê] ..), , , ( ):
Pattern regex = Pattern.compile("[âê]");
StringBuffer resultString = new StringBuffer();
Matcher regexMatcher = regex.matcher(translatedText);
while (regexMatcher.find()) {
String match = regexMatch.group();
String replacement;
switch (match) {
}
regexMatcher.appendReplacement(resultString, replacement);
}
regexMatcher.appendTail(resultString);
translatedText = resultString.toString();
- ( ):
Pattern regex = Pattern.compile("[âê]");
StringBuffer resultString = null;
Matcher regexMatcher = regex.matcher(translatedText);
while (regexMatcher.find()) {
if (resultString == null) {
resultString = new StringBuffer(translatedText.length() + 100);
}
String match = regexMatch.group();
String replacement;
switch (match) {
}
regexMatcher.appendReplacement(resultString, replacement);
}
if (resultString != null) {
regexMatcher.appendTail(resultString);
translatedText = resultString.toString();
}