/* http://es.stackoverflow.com/q/32672/127 */
import java.util.*;
import java.lang.*;
import java.util.regex.*;
class Ideone
{
{
String cadena
= "Respuesta de SO en inglés";
String patronBuscado
= Pattern.
quote(buscar.
toString());
String patronReemplazo
= Matcher.
quoteReplacement(reemplazar.
toString());
Pattern pat = Pattern.compile(patronBuscado, Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE);
Matcher mat = pat.matcher(cadena);
if (mat.find()) {
cadena = mat.replaceAll(patronReemplazo);
System.
out.
println("Resultado: " + cadena
); } else {
System.
out.
println("No se encontro el texto"); }
}
}
LyogaHR0cDovL2VzLnN0YWNrb3ZlcmZsb3cuY29tL3EvMzI2NzIvMTI3ICovCgppbXBvcnQgamF2YS51dGlsLio7CmltcG9ydCBqYXZhLmxhbmcuKjsKaW1wb3J0IGphdmEudXRpbC5yZWdleC4qOwoKY2xhc3MgSWRlb25lCnsKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluIChTdHJpbmdbXSBhcmdzKSB0aHJvd3MgamF2YS5sYW5nLkV4Y2VwdGlvbgoJewoJCVN0cmluZyBjYWRlbmEgPSAiUmVzcHVlc3RhIGRlIFNPIGVuIGluZ2zDqXMiOwoJICAgIAoJICAgIFN0cmluZ0J1ZmZlciBidXNjYXIgPSBuZXcgU3RyaW5nQnVmZmVyKCJFTiBJTkdMw4lTIik7CgkgICAgU3RyaW5nIHBhdHJvbkJ1c2NhZG8gPSBQYXR0ZXJuLnF1b3RlKGJ1c2Nhci50b1N0cmluZygpKTsKCSAgICAKCSAgICBTdHJpbmdCdWZmZXIgcmVlbXBsYXphciA9IG5ldyBTdHJpbmdCdWZmZXIoImVuIGVzcGHDsW9sIik7CgkgICAgU3RyaW5nIHBhdHJvblJlZW1wbGF6byA9IE1hdGNoZXIucXVvdGVSZXBsYWNlbWVudChyZWVtcGxhemFyLnRvU3RyaW5nKCkpOwoJICAgIAoJICAgIFBhdHRlcm4gcGF0ID0gUGF0dGVybi5jb21waWxlKHBhdHJvbkJ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