python - Regex - Match each item between multiple occurrences of delimiter -
i match values between given delimiter using regex expression in python. ignore surrounding white space. example:
the string
1, b cc, "a"and delimiter,return 3 matches of1,b cc,"a"the string
4 + 5 + 2 +1, delimiter+return 4 matches of4,5,2,1
you can re.split() method.
import re re.split('\s*,\s*', '1, b cc, "a"') re.split('\s*\+\s*', '4 + 5 + 2 +1')
Comments
Post a Comment