Use a zero-width (negative) look-behind (?<!) to verify that the space isn't preceded by a "[" without balancing "]":
Be warned that I didn't try this, but it should be close. Regular expressions, the most useful write-only medium in existence Don't forget to escape the backslashes if you put this in a String literal.
Mmmmm, I don't think that will work well, Peter. (Welcome back, BTW!) I get:
Java.util.regex only does lookbehind if it can determine a maximum length to what it's looking for. Other regex packages may only do it if the expression has a single fixed length. Friedl discusses this, but I don't have my copy with me right now.
It may be possible to adapt this pattern for the problem at hand, but I don't see an easy way to do it. I think it will be easier to write a pattern to match the non-whitespace (or anything enclosed in braces) instead. E.g.:
For the problem, as stated, the following should work.
However, it doesn't work with nested structures.
What we're saying here is the following. A space, that is followed any sequence of characters, so long as those characters are anything other then a open or closed bracket, but which end with a closed bracket