Split Method Delimiters


I’m confused on a couple of solutions for both the split method and combing that with the join method. In both examples, the answer includes (/\W/) and I can’t seem to find what that does exactly via Google. Here’s the original problem with the solution in it. What does the W mean?

In the description of the challenge it shows: otherString.split(/\d/), which appears to remove digits from a string. But I can’t seem to come up with what “W” might stand for.

function splitify(str) {
  // Only change code below this line

return str.split(/\W/);

  // Only change code above this line

splitify("Hello World,I-am code");

It’s a Regex
/\W/ or /[^A-Za-z0-9_]/ matches “%” in "50%

/\W/ is a regular expression for non latin word characters means it represent any characters other than A-Z,a-z,0-9 and underscore(_)

1 Like

Thank you! I just couldn’t seem to find that in MDN myself, thank you for linking it!

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.