Search
 
SCRIPT & CODE EXAMPLE
 

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"]
Comment

javascript split string by multiple characters

let string = "Hello awesome, world!"
string.split(/[s,]+/)
// Hello,awesome,world!
Comment

PREVIOUS NEXT
Code Example
Javascript :: express minify html 
Javascript :: react native inline style 
Javascript :: debounce javascript 
Javascript :: remove table line button html using javascript 
Javascript :: infinite scroll jquery 
Javascript :: How to set the background image URL of an element using jQuery 
Javascript :: how to convert seconds in hours minutes and seconds js 
Javascript :: how to convert string to camel case in javascript 
Javascript :: remove letter until vowel javascript 
Javascript :: jest listen EADDRINUSE: address already in use :::5000 jest 
Javascript :: css on javascript 
Javascript :: footer react 
Javascript :: tochararray in javascript 
Javascript :: using bootstrap with react 
Javascript :: vue js routue push 
Javascript :: time complexity javascript 
Javascript :: create and fill array javascript 
Javascript :: js caps first letter 
Javascript :: react native navigation remove top header screen 
Javascript :: round innerhtml value up javascript 
Javascript :: js count char frequency in string 
Javascript :: How to Close a React Native Modal with a Button 
Javascript :: useLocation 
Javascript :: find object in json array 
Javascript :: send mail in node js without password 
Javascript :: cards in react native 
Javascript :: webpack file-loader 
Javascript :: javascript change title 
Javascript :: how to go back one directory in git bash 
Javascript :: mongoose response to object 
ADD CONTENT
Topic
Content
Source link
Name
9+5 =