In Python, how can one negate an overall regular expression? For example, the regex ...
import re
string='This is a test'
string2='Test too BC '
re.search('[ ][A-Z][A-Z][ ]',string)
<doesn't match>
re.search('[ ][A-Z][A-Z][ ]',string2)
<DOES match>
... but what if I want to match only strings that *don't* have two (and only two) adjacent capital letters?
I tried ...
re.search('[^([ ][A-Z][A-Z][ ])]',string2)
.. but only got a 'mismatch of parentheses' error
Thanks for your help in advance!
import re
string='This is a test'
string2='Test too BC '
re.search('[ ][A-Z][A-Z][ ]',string)
<doesn't match>
re.search('[ ][A-Z][A-Z][ ]',string2)
<DOES match>
... but what if I want to match only strings that *don't* have two (and only two) adjacent capital letters?
I tried ...
re.search('[^([ ][A-Z][A-Z][ ])]',string2)
.. but only got a 'mismatch of parentheses' error
Thanks for your help in advance!