simeonshopov

Match numbers

Feb 20th, 2020
448
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.17 KB | None | 0 0
  1. import re
  2.  
  3. text = input()
  4.  
  5. regex = "(^|(?<=\s))-?\d+(\.\d+)?($|(?=\s))"
  6.  
  7. matches = re.finditer(regex, text)
  8.  
  9. for match in matches:
  10.     print(match.group(0), end=' ')
Advertisement
Add Comment
Please, Sign In to add comment