+ 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

8th Dec 2018, 5:35 PM
Mind To Machine 💻🕆
Mind To Machine 💻🕆 - avatar
3 Respostas
+ 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(" ")); } }
8th Dec 2018, 7:32 PM
visph
visph - avatar
+ 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()
8th Dec 2018, 5:47 PM
Taste
Taste - avatar
0
Taste and visph thank you
8th Dec 2018, 9:09 PM
Mind To Machine 💻🕆
Mind To Machine 💻🕆 - avatar