2018-10-12 15:37:13 -04:00
|
|
|
---
|
|
|
|
title: Match All Non-Numbers
|
|
|
|
---
|
2019-07-24 00:59:27 -07:00
|
|
|
# Match All Non-Numbers
|
2018-10-12 15:37:13 -04:00
|
|
|
|
2019-07-24 00:59:27 -07:00
|
|
|
|
|
|
|
---
|
|
|
|
## Hints
|
|
|
|
|
|
|
|
### Hint 1
|
2018-10-12 15:37:13 -04:00
|
|
|
|
|
|
|
* You should try using a global flag.
|
|
|
|
|
2019-07-24 00:59:27 -07:00
|
|
|
### Hint 2
|
2018-10-12 15:37:13 -04:00
|
|
|
|
|
|
|
* Try a shorthand character for non-digits characters.
|
|
|
|
|
|
|
|
|
2019-07-24 00:59:27 -07:00
|
|
|
---
|
|
|
|
## Solutions
|
|
|
|
|
|
|
|
<details><summary>Solution 1 (Click to Show/Hide)</summary>
|
2018-10-12 15:37:13 -04:00
|
|
|
|
|
|
|
```javascript
|
|
|
|
let noNumRegex = /\D/g;
|
|
|
|
```
|
|
|
|
|
2019-07-24 00:59:27 -07:00
|
|
|
#### Code Explanation
|
2018-10-12 15:37:13 -04:00
|
|
|
|
|
|
|
* The `\D` shorthand character is used to match non-digits characters, it has the same result as using `[^0-9]`;
|
2019-07-24 00:59:27 -07:00
|
|
|
</details>
|