Hi Howard,
Here is a commented version of your regular expression.
(?x) (?# Allow whitespace and comments. )
( (?# Opening of capture 1. )
. (?# Any single character. )
) (?# Closing of capture 1. )
(?! (?# Opening negative lookahead assertion. )
[^(]* (?# Zero or more characters that are not a opening parenthesis. )
\) (?# A closing parenthesis. )
) (?# Closing negative lookahead assertion. )
(?!...) is a Negative lookahead assertion.
It basically says: find occurrences of 'this' that are not followed by 'that' but don't include the 'not that' in the match –– hence the 'lookahead'.
For a detailed explanation check the excellent grep documentation in menu Help > BBEdit Help > Grep Reference link.
So that says:
"Any single character that is not followed by zero or more characters that are not the opening parenthesis, followed by a closing parenthesis."
The double negation makes it difficult to fathom.
The negative lookahead assertion says: skip any match that is followed by '...)' where ... are zero of more not '('.
The digits of the first line are not followed by '...)' -> match.
The first character of the second line '(' is followed by '10)' -> skip
The second character of the second line '1' is followed by '0)' -> skip
The third character of the second line '0' is followed by ')' -> skip
The fourth character of the second line ')' is not followed by '...)' -> match
...
A simpler regular expression that will give the same result (and probably be more performant) is:
(\([^\)]*\)|\d)
"Match any parentheses block or any single digits outside of parentheses blocks."
HTH
Jean Jourdain