java string regexp replace

Java
String input = "abcd";
Pattern p = Pattern.compile("regexp");
String output = p.matcher(input).replaceAll("replacement");
Source

Also in Java: