Guest User

Untitled

a guest
May 21st, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. line = '5320411, 996/7 W/O ABC ANO-20'
  2.  
  3. re.sub('^(S+)s+[0-9]{3}/[0-9]{1}', ',', line)
  4.  
  5. line = '5320411, 996/7 , W/O ABC ANO-20'
  6.  
  7. re.sub(r'(d+/d+)', r'1,', line)
  8.  
  9. # Output
  10. '5320411, 996/7, W/O ABC ANO-20'
  11.  
  12. ( # Start of matching group 1
  13. d+ # Matches 1 or more digits
  14. / # Matches /
  15. d+ # Matches 1 or more digits
  16. ) # End of matching group 1
  17.  
  18. import re
  19. line = '5320411, 996/7 W/O ABC ANO-20'
  20. new_line = re.sub('(?<=d{3}/d{1})s', ' ,', line)
  21.  
  22. '5320411, 996/7 , W/O ABC ANO-20'
Add Comment
Please, Sign In to add comment