import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.function.Function;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
class Ideone {
Pattern pattern = Pattern.compile("([a-z]+)");
pattern,
"eee xxx 233 yyy zzz xxx",
x -> "xxx".equals(x) ? "1" : "0"));
}
Pattern pattern,
Function
<String, String
> fun
) { Matcher matcher = pattern.matcher(input);
while (matcher.find()) {
matcher.appendReplacement(sb, fun.apply(matcher.group()));
}
return sb.toString();
}
}
aW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CmltcG9ydCBqYXZhLnV0aWwuZnVuY3Rpb24uRnVuY3Rpb247CmltcG9ydCBqYXZhLnV0aWwucmVnZXguTWF0Y2hlcjsKaW1wb3J0IGphdmEudXRpbC5yZWdleC5QYXR0ZXJuOwoKY2xhc3MgSWRlb25lIHsKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluIChTdHJpbmdbXSBhcmdzKSB0aHJvd3MgamF2YS5sYW5nLkV4Y2VwdGlvbiB7CgkJUGF0dGVybiBwYXR0ZXJuID0gUGF0dGVybi5jb21waWxlKCIoW2Etel0rKSIpOwogICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbihtYWdpYygKICAgICAgICAJcGF0dGVybiwgCiAgICAgICAgCSJlZWUgeHh4IDIzMyB5eXkgenp6IHh4eCIsIAogICAgICAgIAl4IC0+ICJ4eHgiLmVxdWFscyh4KSA/ICIxIiA6ICIwIikpOwoJfQogICAgcHVibGljIHN0YXRpYyBTdHJpbmcgbWFnaWMoCiAgICAJCVBhdHRlcm4gcGF0dGVybiwgCiAgICAJCVN0cmluZyBpbnB1dCwgCiAgICAJCUZ1bmN0aW9uPFN0cmluZywgU3RyaW5nPiBmdW4pIHsKICAgICAgICBNYXRjaGVyIG1hdGNoZXIgPSBwYXR0ZXJuLm1hdGNoZXIoaW5wdXQpOwogICAgICAgIFN0cmluZ0J1ZmZlciBzYiA9IG5ldyBTdHJpbmdCdWZmZXIoKTsKICAgICAgICB3aGlsZSAobWF0Y2hlci5maW5kKCkpIHsKICAgICAgICAgICAgbWF0Y2hlci5hcHBlbmRSZXBsYWNlbWVudChzYiwgZnVuLmFwcGx5KG1hdGNoZXIuZ3JvdXAoKSkpOwogICAgICAgIH0KICAgICAgICByZXR1cm4gc2IudG9TdHJpbmcoKTsKICAgIH0KfQ==