The following expression will complete the task using the forward-looking statement.
_(?>[^[\]]*(\[|$))
The underline is a space. This expression does not support nested parentheses because the regular expression is not powerful enough to express nested matched structures.
_ Match the space and (?> assert that it is not inside brackets [^[\]]* by matching all characters except brackets ( followed by either \[ an opening bracket (a space inside brackets will have a closing bracket at this position) | or $ or no more characters (end of line). ) )
UPDATE
Here is another (and more beautiful) solution that uses a negative forecast statement.
_(?![^[\]]*])
He claims that the next bracket after a space is not a closing bracket.
source share