Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. import re
  2.  
  3. re_string = "(\d+\.\d+|\d+|)(\D*)\s(ohms)"
  4.  
  5. inputs = [
  6. "10 ohms",
  7. "100 ohms",
  8. "220 ohms",
  9. "330 ohms",
  10. "470 ohms",
  11. "680 ohms",
  12. "1k ohms",
  13. "10k ohms",
  14. "22k ohms",
  15. "47k ohms",
  16. "4.7k ohms",
  17. "100k ohms",
  18. "330k ohms",
  19. "2M ohms"
  20. ]
  21.  
  22. for input in inputs:
  23. i = re.search(re_string, input)
  24. print(i.group(1))
  25. print(i.group(2))
  26. print(i.group(3))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement