Regular Expressions - asterisk
See original GitHub issueDescribe your problem and - if possible - how to reproduce it
I find this challenge’s instructions pretty confusing. I made the hard part bold.
The last challenge used the plus + sign to look for characters that occur one or more times. There’s also an option that matches characters that occur zero or more times.
The character to do this is the asterisk or star: *.
let soccerWord = "gooooooooal!"; let gPhrase = "gut feeling"; let oPhrase = "over the moon"; let goRegex = /go*/; soccerWord.match(goRegex); // Returns ["goooooooo"] gPhrase.match(goRegex); // Returns ["g"] oPhrase.match(goRegex); // Returns null
Create a regex chewieRegex that uses the * character to match all the upper and lower"a" characters in chewieQuote. Your regex does not need flags, and it should not match any of the other quotes.
somehow this worked:
let chewieQuote = "Aaaaaaaaaaaaaaaarrrgh!";
let chewieRegex = /Aa*/; // Change this line
let result = chewieQuote.match(chewieRegex);
Here are tests:
- Your regex chewieRegex should use the * character to match zero or more a characters.
- Your regex chewieRegex should match 16 characters.
- Your regex should match “Aaaaaaaaaaaaaaaa”.
- Your regex should not match any characters in “He made a fair move. Screaming about it can’t help you.”
- Your regex should not match any characters in “Let him have it. It’s not wise to upset a Wookiee.”
4th test is especially confusing. there are lowercase ‘a’, why should I not(added after edit) match them?
Add a Link to the page with the problem
Issue Analytics
- State:
- Created 5 years ago
- Comments:18 (11 by maintainers)
Top Results From Across the Web
How to Read and Use Regular Expressions | Hall
The asterisk is known as a repeater symbol, meaning the preceding character can be found 0 or more times. For example, the regular...
Read more >Oracle Regular Expressions Pocket Reference [Book] - O'Reilly
The asterisk ( * ) is a quantifier that applies to the preceding regular expression element. It specifies that the preceding element may...
Read more >Regular Expressions - Pages supplied by users
A regular expression followed by an asterisk ( * ) matches zero or more occurrences of the regular expression. If there is any...
Read more >Asterisk in regex - Stack Overflow
1. $ by default means end of string. You might need MULTILINE flag if you want it to match end of line 2....
Read more >Basic Regular Expressions: Kleene Star
The character * in a regular expression means "match the preceding character zero or many times". For example A* matches any number (including...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@scissorsneedfoodtoo This bug has nothing to do with the asterisk being tricky. It has to do with the fact that the instructions are just plain wrong.
The instructions say:
This means a RegEx like
/[Aa]*/g
What the instructions should say is:
Now we get to the desired RegEx of
/A[Aa]*/g
I’ll file a PR soon1 to resolve the issue of wording.
1 - 0 to 2 days