Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

split string on multiple characters javascript

You can pass a regex into JavaScript's split() method. For example:

"1,2 3".split(/,| /) 
["1", "2", "3"]
Or, if you want to allow multiple separators together to act as one only:

"1, 2, , 3".split(/(?:,| )+/) 
["1", "2", "3"]
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #split #string #multiple #characters #javascript
ADD COMMENT
Topic
Name
5+2 =