+ 1
Some regex help please
given: String text = "Samy16Dave12Carla4David21Jerry10"; can i write a program to put a space between the names and numbers using regex? please also give an example if you can
3 RĂ©ponses
+ 4
import java.util.regex.*;
public class Program {
public static void main(String[] args) {
Pattern p = Pattern.compile("(?<=[^\\d])(?=\\d)|(?<=\\d)(?=[^\\d])");
Matcher m = p.matcher("Samy16Dave12Carla4David21Jerry10");
System.out.println(m.replaceAll(" "));
}
}
+ 2
Select the number, then replace it with itself with space at before and after the number, then trim
Its the js
"ab12bv42kh23".replace(/([0-9]+)/g," $1 ").trim()