python - Regex - how to capture many words -


i have simple regex question:

given string "test-class" regex should use ['test','class'] (in python context)

you don't need regex; use str.split():

>>> 'test-class'.split('-') ['test', 'class'] 

a regex solution still split:

>>> import re >>> re.split(r'-', 'test-class') ['test', 'class'] 

Comments

Popular posts from this blog

python - matpltolib navigation toolbar edit curves and parameters line color automatically changes issue -

node.js - Nodejs javascript implementation of PBEWithMD5AndTripleDES/CBC/PKCS5Padding -