fork(1) download
  1. import re
  2.  
  3. regex = r"\b(?:Length|Width|Height|Weight) (?:\.\d{1,2}|\d{1,4}\.?\d{0,2}|\d{5}\.?\d?|\d{6}\.?) (?:in|oz|lbs|VAC|Hz|amps|H\.P\.|kg)(?!\S)"
  4.  
  5. test_str = ("Width 3.5 in\n"
  6. "Weight 10 kg\n"
  7. "Weight 10 H.P.")
  8.  
  9. print(re.findall(regex, test_str))
Success #stdin #stdout 0.02s 9632KB
stdin
Standard input is empty
stdout
['Width 3.5 in', 'Weight 10 kg', 'Weight 10 H.P.']