[Answered ]-URL regular expression help

1👍

Change the square brackets to round () brackets. The way it is now matches any of the characters a d d | r e etc…

1👍

This happens because [...] matches any character from set. Just remove bracers (using bracers from (?P<>...) is usually enough):

r'(?P<add_or_remove>add|remove)/'

0👍

I’ll admit I’m not familiar with Python. But if your trying to capture add or remove, your syntax is wrong. That is to say you don’t want the brackets as this is notation for a character set – matching any in the set.

r'(?P<add_or_remove>add|remove)/'

Leave a comment