fork(2) download
  1. import re
  2. strings = [
  3. ['28k ring to be worn', '90w20h','96k watch', 'final price'],
  4. ['28k ring to be worn', '90.8w20.6h','96k watch', 'final price'],
  5. ['28k ring to be worn','90.8 w 20.6h','96k watch', 'final price'],
  6. ['28k ring to be worn', '90.8 20.6h','96k watch', 'final price']
  7. ]
  8. for text in strings:
  9. matches = re.findall(r'\d+(?:\.\d+)?k|(\d+(?:\.\d+)?)', ' '.join(text), re.I)
  10. print( [m for m in matches if m!=''] )
Success #stdin #stdout 0.03s 9296KB
stdin
Standard input is empty
stdout
['90', '20']
['90.8', '20.6']
['90.8', '20.6']
['90.8', '20.6']