Files

43 lines
1.4 KiB
Markdown
Raw Normal View History

2018-10-12 15:37:13 -04:00
---
title: Match Single Characters Not Specified
---
# Match Single Characters Not Specified
---
## Problem Explanation
2018-10-12 15:37:13 -04:00
In this challenge, we are asked to return a collection of matches that are not exactly specified. Whereas previous regexp challenges would have you match within the character case [a-z], this challenge instead asks us to negate these matches using the caret character [^a-z]. Our goal then is to return a negated collection (non-matches) of letters that are not vowels nor numbers.
---
## Hints
### Hint 1
Did you remember to surround your regexp in both brackets and slashes?
2018-10-12 15:37:13 -04:00
```javascript
let exampleRegExp = /[^a-z]/;
```
If so, then double check you're adding the appropriate flags:
* i : Ignores upper and lower case from search/match
* g : Retrieves multiple values; default is set to return the first match it encounters
* ^ : Negates the matches following this flag
### Hint 2
Be sure to check whether your number range is correct -- the challenge asks us to negate all numbers from 0 to 9. This can be done using the negate caret placed immediately after the first opening bracket of your regexp.
```js
let numbersRegExp = /[^0-9]/gi;
2018-10-12 15:37:13 -04:00
```
---
## Solutions
<details><summary>Solution 1 (Click to Show/Hide)</summary>
2018-10-12 15:37:13 -04:00
```javascript
let quoteSample = "3 blind mice.";
let myRegex = /[^aeiou^0-9]/gi; // Change this line
2018-10-12 15:37:13 -04:00
let result = quoteSample.match(myRegex); // Change this line
```
</details>