0

I'm trying to split a string that contains both a comma and the word 'and'.

Example:

'one, two and three'

I can get a split working on the comma or the 'and', but not both.

Could anyone help please?

The closest I got was:

str = 'one, two and three'

str.split(/,\W+/)

> ["one", "two and three"]
Tom
  • 905
  • 1
  • 12
  • 27

0 Answers0