fork download
  1. import re
  2.  
  3. regex = r"(?<!\S)\d+(?:,\d+)? ?x ?\d+(?:,\d+)?(?: ?x ?\d+(?:,\d+)?)*"
  4. test_str = ("Square 10 x 3 x 5 mm\n"
  5. "Round 23/22; 24,9 x 12,2 x 12,3\n"
  6. "Square 10x2\n"
  7. "Straight 10x2mm\n"
  8. "Round 23/22; 24,9x12,2")
  9. result = re.findall(regex, test_str)
  10. print(result)
Success #stdin #stdout 0.02s 9392KB
stdin
Standard input is empty
stdout
['10 x 3 x 5', '24,9 x 12,2 x 12,3', '10x2', '10x2', '24,9x12,2']