+
para buscar uno o más caracteres y el asterisco *
para buscar cero o más caracteres. Estos son convenientes, pero a veces usted quiere hacer coincidir un cierto rango de patrones. Puede especificar el número inferior y superior de patrones con quantity specifiers
. Los especificadores de cantidad se utilizan con llaves ( {
y }
). Pones dos números entre las llaves: para el número inferior y superior de patrones. Por ejemplo, para hacer coincidir solo la letra a
aparece entre 3
y 5
veces en la cadena "ah"
, su expresión regular sería /a{3,5}h/
. sea A4 = "aaaah";
sea A2 = "aah";
deja multipleA = / a {3,5} h /;
prueba múltiple (A4); // Devuelve true
prueba múltiple (A2); // Devuelve falso
ohRegex
para que coincida solo con 3
a 6
letras h
en la palabra "Oh no"
. "Ohh no"
testString: 'assert(!ohRegex.test("Ohh no"), "Your regex should not match "Ohh no"
");'
- text: Tu expresión regular debe coincidir con "Ohhh no"
testString: 'assert(ohRegex.test("Ohhh no"), "Your regex should match "Ohhh no"
");'
- text: Tu expresión regular debe coincidir con "Ohhhh no"
testString: 'assert(ohRegex.test("Ohhhh no"), "Your regex should match "Ohhhh no"
");'
- text: Tu expresión regular debe coincidir con "Ohhhhh no"
testString: 'assert(ohRegex.test("Ohhhhh no"), "Your regex should match "Ohhhhh no"
");'
- text: Tu expresión regular debe coincidir con "Ohhhhhh no"
testString: 'assert(ohRegex.test("Ohhhhhh no"), "Your regex should match "Ohhhhhh no"
");'
- text: Tu expresión regular no debe coincidir con "Ohhhhhhh no"
testString: 'assert(!ohRegex.test("Ohhhhhhh no"), "Your regex should not match "Ohhhhhhh no"
");'
```