fork download
  1. import re
  2. source = 'mystring/1234567890 hello world mystring/2345678901 hello'
  3. matches = re.finditer(r"\bmystring/(\d{10})(?!\d)", source)
  4. for match in matches:
  5. print("Whole match: {}".format(match.group(0)))
  6. print("Group 1: {}".format(match.group(1)))
  7. # or just
  8. print(re.findall(r"\bmystring/(\d{10})(?!\d)", source))
Success #stdin #stdout 0.02s 27712KB
stdin
Standard input is empty
stdout
Whole match: mystring/1234567890
Group 1: 1234567890
Whole match: mystring/2345678901
Group 1: 2345678901
['1234567890', '2345678901']