fork download
  1. import re
  2.  
  3. regex = r"(\w+(?: \w+)*(?: \([^()]*\))?) (\d+|[¼½¾]) (\w+(?: \w+)*)"
  4. s = "Some text (just as 1 example) ¼ more words"
  5. match = re.match(regex, s)
  6. if match:
  7. print(match.group(1))
  8. print(match.group(2))
  9. print(match.group(3))
Success #stdin #stdout 0.02s 9384KB
stdin
Standard input is empty
stdout
Some text (just as 1 example)
¼
more words