I have String like this: "LODIXAL COMP 15"
How can i split it to "LODIXAL COMP" and "15" ?
String a = "LODIXAL COMP 15";
String[] result = {"LODIXAL COMP" , "15"}
Use this positive lookahead based regex:
a.split(" (?=\\d+)");
TESTING:
System.out.println(Arrays.toString(a.split(" (?=\\d+)")));
OUTPUT:
[LODIXAL COMP, 15]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With