does anybody know if there is a solid library based method to achieve the following.
say I have a string:
"name1, name2, name3, name4"
and I want to parse it into 2 strings based on the comma delimiter.
I would like the strings to look like this
string1 = "name1";
string2 = "name2, name3, name4";
any ideas?
thanks, m
解决方案
Pattern pattern = Pattern.compile(", *");
Matcher matcher = pattern.matcher(inputString);
if (matcher.find()) {
string1 = inputString.substring(0, matcher.start());
string2 = inputString.substring(matcher.end());
}