quantity specifiers
usando chaves. Às vezes você só quer especificar o menor número de padrões sem limite superior. Para especificar apenas o menor número de padrões, mantenha o primeiro número seguido por uma vírgula. Por exemplo, para corresponder apenas à string "hah"
com a letra a
aparecer pelo menos 3
vezes, seu regex seria /ha{3,}h/
. deixe A4 = "haaaah";
seja A2 = "haah";
seja A100 = "h" + "a" .repetição (100) + "h";
vamos multipleA = / ha {3,} h /;
multipleA.test (A4); // Retorna true
multipleA.test (A2); // Retorna falso
multipleA.test (A100); // Retorna true
haRegex
para coincidir com a palavra "Hazzah"
apenas quando tiver quatro ou mais letras z
. "Hazzah"
testString: 'assert(!haRegex.test("Hazzah"), "Your regex should not match "Hazzah"
");'
- text: Seu regex não deve corresponder a "Hazzzah"
testString: 'assert(!haRegex.test("Hazzzah"), "Your regex should not match "Hazzzah"
");'
- text: Seu regex deve coincidir com "Hazzzzah"
testString: 'assert(haRegex.test("Hazzzzah"), "Your regex should match "Hazzzzah"
");'
- text: Seu regex deve coincidir com "Hazzzzzah"
testString: 'assert(haRegex.test("Hazzzzzah"), "Your regex should match "Hazzzzzah"
");'
- text: Seu regex deve coincidir com "Hazzzzzzah"
testString: 'assert(haRegex.test("Hazzzzzzah"), "Your regex should match "Hazzzzzzah"
");'
- text: 'Seu regex deve combinar "Hazzah"
com 30 z
\ 's nele.'
testString: 'assert(haRegex.test("Ha" + "z".repeat(30) + "ah"), "Your regex should match "Hazzah"
with 30 z
\"s in it.");'
```