Issue
I want to split 'E100N05' into ['E100', 'N05'] , so split after a number become the letter N, E, S or W. The number of digits after a letter can be different.
import re
re.split('[NSEW$*]', 'E100N05')
Out[8]: ['', '100', '05']
What I want : ['E100','N05']
Which pattern should I use?
Solution
Try this:
>>> re.split('(?!^)(?=[NSEW$])', 'E100N05')
['E100', 'N05']
>>>
Answered By - U12-F̉͋̅̾̇orward
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.