2018-10-04 14:47:55 +01:00
|
|
|
---
|
|
|
|
title: Match Everything But Letters and Numbers
|
|
|
|
---
|
2019-07-24 00:59:27 -07:00
|
|
|
# Match Everything But Letters and Numbers
|
2018-10-04 14:47:55 +01:00
|
|
|
|
2019-07-24 00:59:27 -07:00
|
|
|
---
|
|
|
|
## Problem Explanation
|
2019-03-08 23:53:49 +01:00
|
|
|
To finish this challenge, it's necessary to use __character classes__.
|
2018-10-04 14:47:55 +01:00
|
|
|
|
2019-03-08 23:53:49 +01:00
|
|
|
The __\W__ matches any character that is not a word character from the basic Latin alphabet.
|
|
|
|
__Equivalent to [^A-Za-z0-9_].__
|
|
|
|
|
2019-07-24 00:59:27 -07:00
|
|
|
For example, `/\W/` or `/[^A-Za-z0-9_]/` matches "%" in "50%".
|
2019-03-08 23:53:49 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2019-07-24 00:59:27 -07:00
|
|
|
---
|
|
|
|
## Solutions
|
|
|
|
|
|
|
|
<details><summary>Solution 1 (Click to Show/Hide)</summary>
|
2019-03-08 23:53:49 +01:00
|
|
|
|
|
|
|
```javascript
|
|
|
|
let quoteSample = "The five boxing wizards jump quickly.";
|
|
|
|
let nonAlphabetRegex = /\W/g; // Change this line
|
|
|
|
let result = quoteSample.match(nonAlphabetRegex).length;
|
|
|
|
```
|
2019-07-24 00:59:27 -07:00
|
|
|
</details>
|