How can i split a string by dot, comma and newline with removing whitespaces by using regex in javascript? -


i have string this:

what, inclined to, hi . hello  

i want split this:

["what","be inclined to","hi","hello","where"] 

currently i'm using regex doesn't work want:

input_words.val().replace(/^\s*|\s*$/g, '').split(/\n|\s*,|\./); 

split function alone enough. below regex split input according 1 or more commas or dots or newline characters along preceding or following 0 or more spaces.

var s = "what, inclined to, hi . hello\nwhere";  alert(s.split(/\s*[,\n.]+\s*/))


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -