fork download
  1. import re
  2.  
  3. regex = r"\b(?P<weight>\d+)\"\s*w\s*x\s*(?P<depth>\d+)\"\s*d\s*x\s*(?P<height>\d+)\"\s*h\b"
  4.  
  5. s = "84\" w x 39\" d x 37\" h"
  6.  
  7. matches = re.finditer(regex, s)
  8.  
  9. for matchNum, match in enumerate(matches, start=1):
  10. weight = match.group("weight")
  11. depth = match.group("depth")
  12. height = match.group("height")
  13.  
  14. print(weight, depth, height)
Success #stdin #stdout 0.02s 9448KB
stdin
Standard input is empty
stdout
84 39 37