FAQ: Learn HTML: Form Validation - Matching a Pattern

This community-built FAQ covers the "Matching a Pattern " exercise from the lesson “Learn HTML: Form Validation”.

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

Introduction to HTML

FAQs on the exercise _Matching a Pattern _

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!

25 posts were split to a new topic: What are quantifiers? (the + and {14,16})

6 posts were split to a new topic: Does HTML regex follow the same rules as Javascript?

2 posts were split to a new topic: How to use special characters in regex?

2 posts were split to a new topic: Can this replace minlength and maxlength?

2 posts were split to a new topic: How to enter accented letters?

2 posts were split to a new topic: Why is the type text and not number?

For those having a hard time with regular expressions, I’d recommend https://regexone.com/

It’s an interactive tutorial to teach you the basics of regular expressions. The tutorial could have been better, but it’s more approachable than the overwhelming complete list of regular expressions as in the MDN documentation.

3 Likes

Why are we not using the “+” modifier/identifier in the Credit Card Value regex?? Shouldn’t those numbers also occur one or more times as “+” indicates? Or is it written this way purely because the photo shows each number only used once??

7 posts were split to a new topic: Why is a credit card number using type text?

How would you mandate a certain number of numbers, letters, uppercase letters, or characters in a username or password? For example, “password must include 1 uppercase, 1 lowercase, 1 number, and 1 special character”.

Also, are these patterns something the coder creates? Or is there a set of patterns to follow? How do you build a pattern? This was probably answered in the regex article, I had a hard time following it, super new to coding.

Having the same question. Following if someone replies.

I am eager to start a topic and ask my own questions, but I am not able to. I don’t see any instructions on how to create topics.
Help

This is a great video for understanding regular expressions!

2 Likes

I probably just haven’t gotten there yet, but what is the character “+” being used for here? I don’t recall seeing anything on it in previous pages

+ is a quantifier that specifies ‘1 or more’. In other words, at least one.

Quantifiers +, *, ? and {n}

" We could use the regex: [0-9]{14,16} which checks that the user provided only numbers and that they entered at least 14 digits and at most 16 digits."

Why don’t we use the min and max attibutes to limit the number of digits to min 14 and max 16?

I have a question about the regex in this lesson: [a-zA-Z0-9]+

Why are the criteria not separated at all and are just a runon? For example, why wouldn’t it be [a-z, A-z, 0-9] or something like that? Why does it not register is as “zA” and still understands you mean “z” and “A” (or “Z” and “0”)?

I think that’s because spaces and commas have other meanings in regular expressions.

Hello,

Why in example with Credit Card Number we use type=“text”, not type=“number”?