fork download
  1. import re
  2.  
  3. regex = r"\[H] (.+?) \[W] (.+)"
  4. test_str = "[H] $10 [W] 100 credits"
  5.  
  6. matches = re.search(regex, test_str)
  7. if matches:
  8. variable1 = matches.group(1)
  9. variable2 = matches.group(2)
  10.  
  11. print(variable1)
  12. print(variable2)
Success #stdin #stdout 0.02s 9476KB
stdin
Standard input is empty
stdout
$10
100 credits