¡GoConqr estrena diseño! Cuéntanos qué te parece.

Módulo 21 de 33 · Multimedia

Quantifiers

Kostas Diakogiannis

Quantifiers

Quantifiers 

Quantifiers are used when we don't know exactly from how many characters our pattern is comprised of. For example we want to accept names from an input html field. That means that we should accept all possible letters from A to Z. 

We could use a character set in this case like [A-Z], but this is only for one character. We would like to repeat this process for all characters of a string. 

In case you know the exact number of letters you want your pattern to match you can use the curly braces as quantifier to have something like /^[a-z]{10}$/i. This matches a string that is comprised exclusively from 10 letters. 

With the + quantifier you can use the same pattern for any amount of repetitions if you don't care about the exact length of the data that you are going to accept. ex: /^[a-z]+$/i

Other regex quantifiers for defining the minimum or the maximum amount of a character that is allowed can be found above.

 

Instrucciones

Para avanzar en el curso, envía un intento de este test. Puedes enviarlo después de la última pregunta.

Ir al módulo elegido

Escríbenos

¿Sobre qué es tu mensaje?

¿Qué te parece el nuevo diseño?

¿Te gusta?