How to use re.split for commas and periods?

Viewed 15197

I have multiple strings where words are split with commas or periods:

string = ['apple,pear,grapes,carrot.cabbage,veggies.fruit,yard']

I would like to split this based on commas and periods:

string = ['apple','pear','grapes','carrot','cabbage','veggies','fruit','yard']

I only know how to use one condition for re.split:

re.split(',',string)

this won't split words that have periods in between. How can I split the whole string so that words are split when there are commas or periods in between?

3 Answers
Related