I want to split incoming mail messages into word array. smth like this:
"Hi,.***Build, son,!8loop"
into
['Hi' , 'Build', 'son', 'loop']
i know you want to send me to learn it by myself but i’ve read alot of articles but still no ideas.
p.s. using regex+javascript
You can do the following:
Replace all non-word characters by a white space:
You might have to adjust this to your needs, to replace the right characters:
\Wmatches everything expect letters, digits, and underscores\dmatches digits\smatches white spacesThere are other ways to write an equivalent expression.
Then split bye white space:
Regular-Expressions.info is a good website to learn about regular expressions. For regular expressions in JavaScript, have a look at the MDC documentation.