Would anyone be able to assist me with some regex.
I want to split the following string into a number, string number
\"810LN15\"
1 metho
In Java, as in most regex flavors (Python being a notable exception), the split()
regex isn't required to consume any characters when it finds a match. Here I've used lookaheads and lookbehinds to match any position that has a digit one side of it and a non-digit on the other:
String source = "810LN15";
String[] parts = source.split("(?<=\\d)(?=\\D)|(?<=\\D)(?=\\d)");
System.out.println(Arrays.toString(parts));
output:
[810, LN, 15]