I have a bunch of string look like
aaa -bx or
aaa -bxx where
x would be a digit. Is there any way to mach
bxx without using regrex? I remember there is something like
b_ to match it.
You can use string methods.
aaa -b followed by digits:
def match(s): start = 'aaa -b' return s.startswith(start) and s[len(start):].isdigit() match('aaa -b33') # True
If you rather want to check if the part after the last
b are digits, use
Answered By – mozway
Answer Checked By – Senaida (BugsFixing Volunteer)