From baed72fd3d0d46faf9d28a3c0a7a12e41e64534a Mon Sep 17 00:00:00 2001 From: Andrei Calinescu Date: Sat, 9 Mar 2019 07:41:08 +0900 Subject: [PATCH] Explained solution and added alternate (#34718) * Explained solution and added alternate Explained why the solution works and added an alternate, less elegant solution for comparison. * Removed last line per feedback --- .../index.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/guide/english/certifications/javascript-algorithms-and-data-structures/functional-programming/split-a-string-into-an-array-using-the-split-method/index.md b/guide/english/certifications/javascript-algorithms-and-data-structures/functional-programming/split-a-string-into-an-array-using-the-split-method/index.md index 1fe7599d4b..5e35c395e0 100644 --- a/guide/english/certifications/javascript-algorithms-and-data-structures/functional-programming/split-a-string-into-an-array-using-the-split-method/index.md +++ b/guide/english/certifications/javascript-algorithms-and-data-structures/functional-programming/split-a-string-into-an-array-using-the-split-method/index.md @@ -7,6 +7,8 @@ Simply split the string to create a new array of words. A simple regular expression can be used to achieve this result. +`/\W/` Matches any non-word character. This includes spaces and punctuation, but not underscores. It's equivalent to `/[^A-Za-z0-9_]/`. For more information about Regular Expressions, see the official [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions). + ### Solution ```javascript function splitify(str) {