Answers for "java string replace regex"

0

java string regexp replace

String input = "abcd";
Pattern p = Pattern.compile("regexp");
String output = p.matcher(input).replaceAll("replacement");
Posted by: Guest on March-26-2020
0

replace regex group() java

Pattern p = Pattern.compile("(\d)(.*)(\d)");
String input = "6 example input 4";
Matcher m = p.matcher(input);
if (m.find()) {
    // replace first number with "number" and second number with the first
    String output = m.replaceFirst("number $3$1");  // number 46
}
Posted by: Guest on June-24-2020
0

java replaceall regex

str.replaceAll("\^([0-9]+)", "<sup>$1</sup>");
Posted by: Guest on November-29-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language