I have absolutely no idea how Regex works. I'm using this bit of Regex to match arguments for the URL dispatcher:
r'^/(?P<c>\d+)/(?P<b>\d+)/(?P<g>\w+)'
The issue is that the second value b
will not match if it's a negative. How can I change the above regex so it matches negative numbers as well as positive ones for the second value?
r'^/(?P<c>\d+)/(?P<b>-?\d+)/(?P<g>\w+)'
I've added the -?
, which means: match one or zero -
characters.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With