0

How to split a text line into numbers and the text?

How to split a text line into numbers and the text example: asdfsg214356asfgxczv321d4 =>> [asdfsg, 214356, asfgxczv, 321, d, 4]

5th Mar 2018, 5:08 AM
Данил
Данил - avatar
3 odpowiedzi
5th Mar 2018, 6:50 AM
Мг. Кнап🌠
Мг. Кнап🌠 - avatar
+ 8
The obvious solution for pattern matching would be using Regex, just split it by a string of digits while keeping it would do the job. Here's how we do it in C# and I believe it would be similar in Java too. 😉 Regex.Split(str, @"(\d+)");
5th Mar 2018, 5:40 AM
Zephyr Koo
Zephyr Koo - avatar
+ 1
Thanks for answers, i made this code: split("(?<=[\\d])(?=[\\D])|(?<=[\\D])(?=[\\d])");
5th Mar 2018, 7:03 AM
Данил
Данил - avatar