I am trying to craft a delimiter regex (for use with java.util.Scanner) that segments a string on whitespace, as well as keeping colons, opening parenthesis and closing parenthesis as separate tokens. That is, foo(a:b) should segment into the tokens foo, (, a, :, b and ).
My current best effort is the pattern "\\s+|(?=[(:])|(?<=[:)])" which for some reason I can't understand fails to match after the opening parenthesis and before the closing parenthesis, but matches fine on both sides of the colon.