Reputation: 1809
I'm trying to write a regex in Python to match strings such as rds2
, rds5
, rds11
, but not match the string rds1
or any non rds
-followed-by-digits string, e.g. camels2
.
My current regex is just
^rds[^1]
however this doesn't match strings which end in 1 followed by another digit. I am not very familiar with regex, but I think I have to use a look-behind assertion to make sure that at the end of the string, if the last character is 1
then the previous character was [0-9]
?
I attempted to do so, but have ended up in a mess where the look-behind assertion length seems variable on how many digits the string ends with.
Upvotes: 0
Views: 101