FAQ: Introduction to Regular Expressions - Quantifiers - Fixed

This community-built FAQ covers the “Quantifiers - Fixed” exercise from the lesson “Introduction to Regular Expressions”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Practical Data Cleaning

FAQs on the exercise Quantifiers - Fixed

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

It seems to me that in the lesson’s last two paragraphs there is a contradiction.
In the example roa{3,7}r, it is noted that ‘a’ will be at least 3 and at most 7.
However, just below, in the example mo{2,4}, it is noted that ‘o’ will be 4 and not less .

The only difference I can distinguish between these two cases in that in the first , after the word character that the fixed quantifier is applied to (‘a’), another character follows (‘r’).
In the second case, the word character at which the fixed quantifier is applied to (‘o’) , is the last.

So, is it right to conclude that the exact way a fixed quantifier is used depends on the word character’s position (being the last or not) ?

2 Likes

I agree, @jminer583, I have the same question! This does seem contradictory. It seem to me that moo should match mo{2,4}.

I was a bit confused by the last two paragraphs as well.

I think perhaps it isn’t being said that moo or mooo wouldn’t match mo{2,4}, rather that if your string is “moooo”, the match you’d get would always be for the “moooo” aspect not the “moo” or “mooo” aspects of the string.

I’ve probably not explained that very well, apologies!

1 Like

they author says that if you need to confirm

if you give regex like this ( just say if regex is like this, at worst conditions )

s{1,3}sa

it accepts strings like
“ssssa”
but not
“ssa” or “sssa”

… this is because quantifiers are greedy so it covers max number of chars … i hope you understand …