I am reading in lines,and I need to split each line when the delimiter ;
(semicolon + space) is present. Each line is as follows: s1; s2 s3; s4. I want to split this line where ;
(semicolon + space) exists. I want to split only where semicolon and space are adjacent to each other, where a space follows a semicolon.
How would I do this using StringTokenizer?
I have already tried split("; ") but this splits the String at every occurrence of a space.
I have also tried new StringTokenizer(strLine,"\s*;\s+"), but this splits at every occurrence of 's'.
String[] parsedStr = inputString.split(...);
StringTokenizer st = new StringTokenizer(...);
I expect the output to be:
("s1","s2 s3","s4") Every token should be an element within this array.
NOT
("s1"," s2 s3"," s4")
NOR
("s1","s2","s3","s4")