Try
System.out.println("10 and Mayfield and London".replaceAll("(\\p{Alpha}+)", "SYN($1)").replace("SYN(and)", "and"));
output
10 and SYN(Mayfield) and SYN(London)
1
solved regular expression wrapping words [closed]
Try
System.out.println("10 and Mayfield and London".replaceAll("(\\p{Alpha}+)", "SYN($1)").replace("SYN(and)", "and"));
output
10 and SYN(Mayfield) and SYN(London)
1
solved regular expression wrapping words [closed]