split a string based on pattern in java - capital letters and numbers
- by rookie
Hi all
I have the following string "3/4Ton". I want to split it as --
word[1] = 3/4 and word[2] = Ton.
Right now my piece of code looks like this:-
Pattern p = Pattern.compile("[A-Z]{1}[a-z]+");
Matcher m = p.matcher(line);
while(m.find()){
System.out.println("The word --> "+m.group());
}
It carries out the needed task of splitting…