1

I'm trying to match a number between 1 and 3 in a string using a regex:

import re

print(re.match(r'[1-3]{1}', 'a1')) # Prints None
print(re.match(r'[1-3]{1}', '1a')) # Prints <re.Match object; span=(0, 1), match='1'>

While my regex seems to be working correctly both on regex101.com and in JS, for some reason I cannot get it to work in Python3.

Can someone point me to what is wrong here?

Philippe Hebert
  • 1,616
  • 2
  • 24
  • 51

0 Answers0