In Java, can I split a String
from left to right where the left part is an alphabet while the right part is numeric? Assuming the String
is always a valid string (e.g. all string to be evaluated always starts with an alphabet and ends with a whole number/ no decimal places):
L1293 = ["L", "1293"]
WMG16 = ["WMG", "16"]
SP9878558 = ["SP", "9878558"]
Q12 = ["Q", "12"]
APMZ1 = ["APMZ", "1"]
The alphabet part can be virtually range 0 or more length. I've done some tokenizing/looping each character, like checking where the first digit character will appear, and split it there, using Character.isDigit()
, String.indexOf()
, and so on. I'm thinking, maybe there is a one-liner for this.