Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- line = '5320411, 996/7 W/O ABC ANO-20'
- re.sub('^(S+)s+[0-9]{3}/[0-9]{1}', ',', line)
- line = '5320411, 996/7 , W/O ABC ANO-20'
- re.sub(r'(d+/d+)', r'1,', line)
- # Output
- '5320411, 996/7, W/O ABC ANO-20'
- ( # Start of matching group 1
- d+ # Matches 1 or more digits
- / # Matches /
- d+ # Matches 1 or more digits
- ) # End of matching group 1
- import re
- line = '5320411, 996/7 W/O ABC ANO-20'
- new_line = re.sub('(?<=d{3}/d{1})s', ' ,', line)
- '5320411, 996/7 , W/O ABC ANO-20'
Add Comment
Please, Sign In to add comment