Added intro paragraph and further hints.
This commit is contained in:
committed by
Jaka Kranjc
parent
409aa30b0a
commit
36a4df9afa
@ -2,17 +2,17 @@
|
||||
title: Check for All or None
|
||||
---
|
||||
## Check for All or None
|
||||
In this challenge, you are asked to change the regex so that it defines the existence of the letter u, resulting in the acceptance of both American and British versions of the word favourite/favorite.
|
||||
|
||||
With Regular Expressions (RegExp) you can have modify your testing pattern with special charaters. To pass this challenge you the __quantifiers__ are very helpful. A quantifier is __?__ in __x?__.
|
||||
### Hint 1:
|
||||
The variable favWord already contains the American version — favorite. Does the regular expression in favRegex also match the British version?
|
||||
|
||||
__x?__ Matches the preceding item x 0 or 1 time.
|
||||
### Hint 2:
|
||||
Have you used the question mark, ? symbol, if so, have you placed it in the correct position?
|
||||
|
||||
For example, /e?le?/ matches the "el" in "angel" and the "le" in "angle."
|
||||
### Spoiler Alert - Solution Ahead!
|
||||
|
||||
If used immediately after any of the quantifiers *, +, ?, or {}, makes the quantifier non-greedy (matching the minimum number of times), as opposed to the default, which is greedy (matching the maximum number of times).
|
||||
|
||||
|
||||
__Challenge Solution:__
|
||||
## Solution
|
||||
|
||||
```javascript
|
||||
let favWord = "favorite";
|
||||
|
Reference in New Issue
Block a user