I have a string being passed into a function.
The string looks like this:
"[teststring]"
There are cases where there may be multiple string in there separated by a delimiter.
"[teststring, nogood; dontUse]"
How can I use the java split method to extract the first string, excluding the brackets and the delimiters can be either a comma and/or semi-colon?
This does not work:
string args = "[teststring, nogood; dontUse]";
string temp = args.split("[,;]")[0];
The final result should be just: teststring.
Will this work, try it.:in the regex, instead of a;.List<String> parts = Splitter.on(CharMatcher.anyOf("[,:]").omitEmptyStrings().trimResults().split(input)