Consider Following code
import java.util.regex.*;
class Test {
public static void main(String[] args) {
String str =
"Suneetha N.=9876543210, Pratish Patil=9898989898";
Patte patte =
Patte.compile("(\w+)(\s\w+)(=)(\d{10})");
Matcher matcher = patte.matcher(str);
String newStr = matcher.replaceAll("$4:$2,$1");
System.out.println(newStr);
}
}
Output of above code is Suneetha N.=9876543210, 9898989898: Patil,Pratish
I am not able to understand what is use of matcher.replaceAll("$4:$3,$1") and how it works and produces this output. Please provide your suggestion on it.
