updated description

This commit is contained in:
Arjun Mahishi
2017-12-20 12:34:03 +05:30
committed by GitHub
parent 4280957a10
commit 251edb535b

View File

@ -2,11 +2,11 @@
Converts a given string into an array of words Converts a given string into an array of words
Use `String.split(/[\W_]+/)` to convert the string to an array with the use of regex. Use `String.split` to convert the string to an array.
```js ```js
const stringToArrayOfWords = (str, pattern = /[\W_]+/) => str.split(pattern).filter(Boolean) const stringToArrayOfWords = (str, pattern = /[\W_]+/) => str.split(pattern).filter(Boolean)
// stringToArrayOfWords("I love javaScript!!") -> ["I", "love", "javaScript"] // stringToArrayOfWords("I love javaScript!!") -> ["I", "love", "javaScript"]
// stringToArrayOfWords("python, javaScript & coffee") -> ["python", "javaScript", "coffee"] // stringToArrayOfWords("python, javaScript & coffee") -> ["python", "javaScript", "coffee"]
``` ```