2018-10-12 15:37:13 -04:00
|
|
|
---
|
|
|
|
title: Match All Numbers
|
|
|
|
---
|
2019-07-24 00:59:27 -07:00
|
|
|
# Match All 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
|
|
|
|
|
|
|
* A global flag will help you get through this challenge.
|
|
|
|
|
2019-07-24 00:59:27 -07:00
|
|
|
### Hint 2
|
2018-10-12 15:37:13 -04:00
|
|
|
|
|
|
|
* Try using a shorthand character for `d`igits.
|
|
|
|
|
|
|
|
|
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 numRegex = /\d/g;
|
|
|
|
```
|
|
|
|
|
2019-07-24 00:59:27 -07:00
|
|
|
#### Code Explanation
|
2018-10-12 15:37:13 -04:00
|
|
|
|
2019-07-24 00:59:27 -07:00
|
|
|
* The `\d` shorthand character is a shortcut for `[0-9]`, it search for any number between 0 and 9.
|
|
|
|
</details>
|