replace regex group 28 29 java

Solutions on MaxInterview for replace regex group 28 29 java by the best coders in the world

showing results for - "replace regex group 28 29 java"
Ilian
02 Jun 2019
1Pattern p = Pattern.compile("(\\d)(.*)(\\d)");
2String input = "6 example input 4";
3Matcher m = p.matcher(input);
4if (m.find()) {
5    // replace first number with "number" and second number with the first
6    String output = m.replaceFirst("number $3$1");  // number 46
7}