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 of 1,b cc,"a"

  • the string 4 + 5 + 2 +1 , delimiter + return 4 matches of 4,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

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -