I want to use the python re
package to search for strings that start with "[[" that is not followed by "Category:" has an arbitrary number of characters and end with "]]". I tried the following code:
s="blah [[Category:Cartooning]] blah"
regex = re.compile(r"\[\[(?<!Category:).*?\]\]")
res = regex.search(s)
if res!=None:
print(res)
else:
print('no match')
and got the following response:
<re.Match object; span=(5, 28), match='[[Category:Cartooning]]'>
Seems like negative lookbehind does not work. What am I doing wrong? Thanks!