fork download
  1. import re
  2. some_regex = re.compile("^foo(?P<idx>[0-9]*)?$")
  3.  
  4. match = some_regex.match('foo11')
  5. print(match and 'idx' in match.groupdict())
  6.  
  7. match = some_regex.match('bar11')
  8. print(match and 'idx' in match.groupdict())
Success #stdin #stdout 0.03s 9284KB
stdin
Standard input is empty
stdout
True
None