Help with pattern attribute syntax

Hello. I’m on the storytelling project for the forms section of the course, and one of the extra challenges at the end is to use the pattern attribute to restrict what a user can type into a form (or rather what will be allowed by the form in order to move past the submit button).

For the part of the form that wants an adjective word ending in ing, I would like to add a pattern attribute that says that all A-Z/a-z characters are allowed, upto any length, but the word MUST have ‘ing’ on the end.

I have tried pattern="[a-zA-Z](ing)" and a few variations of that, but I cannot find anything that works. Can somebody please tell me the answer to my problem and explain it to me… Thank you. :blush:

It seems you’re pretty close with what you currently have! Just think about the fact you want the [a-zA-Z] to occur one or more times (as in, you want at least one letter before the ing). Think about what character you could use to do that, and where you would place it. This website is great for testing regexes.

1 Like

Hi! Thanks so much for your reply.
I tried (a-zA-z]{*}(ing) yesterday but that didn’t work either. I also tried specifying the number for ing too.

The site you provided looks great but I can’t get along with it. Everything that type in there says it’s failed… It may because it’s running JavaScript and I don’t know the syntax for that?

Many thanks for your patience with me. :slight_smile:

You’re even closer now. But do you need the {} around the asterisk? {} Are either used when you’re trying to match a certain string length (or a certain range of string length), or, if they don’t have a number inside, they just match themselves.

About the site, you don’t need to run full JS code, you can just put the regex in (without any quotation marks that come with it in JS) between the /…/g characters:

1 Like