I have the following String:
"location-string:location-string:location-C?:\string"
which I would like to split into the following three Strings:
location-string
location-string
location-C?:\string
What should the regex expression be when using String.split(regex)?
Basically, I want to split on colon ':' characters except those that are preceded by a '?' character!
Thanks in advance,
PM.
Answer
You could use negative lookbehind. It matches the colon which was not preceeded by ?
(?
Java regex would be,
"(?
No comments:
Post a Comment