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 :: tailwind in react 
Javascript :: regular expression to find a string between two characters 
Javascript :: get current date 
Javascript :: jquery datatables get selected row data 
Javascript :: jQuert latest cdn 
Javascript :: javascript format seconds into minutes and second 
Javascript :: jquery remove click event 
Javascript :: toggle class javascript and jquery 
Javascript :: aos js cdn 
Javascript :: javascript string pop 
Javascript :: javascript object entries 
Javascript :: how to remove element from array in javascript 
Javascript :: print json pretty linux 
Javascript :: import bootstrap css and js file in react 
Javascript :: get checked radio button value jquery by name 
Javascript :: document get element by id radio button 
Javascript :: regular expression match text between quotes 
Javascript :: JS DOM how to add a class name to any HTML element 
Javascript :: javascript move last array element to first 
Javascript :: js image on canvas 
Javascript :: loop array and check if value matches in js 
Javascript :: the submitted data was not a file. check the encoding type on the form django react 
Javascript :: jquery data attribute 
Javascript :: clear localstorage on click jquery 
Javascript :: javascript remove all style values in div 
Javascript :: how to add checkbox in alert box in javascript 
Javascript :: convert milliseconds to minutes and seconds javascript 
Javascript :: ajax call do something while 
Javascript :: how to import background image in inline css in react 
Javascript :: discord.js get username 
ADD CONTENT
Topic
Content
Source link
Name
9+8 =