2.9 KiB
2.9 KiB
id | title | challengeType | videoUrl | localeTitle |
---|---|---|---|---|
587d7db9367417b2b2512ba5 | Specify Upper and Lower Number of Matches | 1 | Especifique o Número Superior e Inferior de Correspondências |
Description
+
para procurar um ou mais caracteres e o asterisco *
para procurar zero ou mais caracteres. Estes são convenientes, mas às vezes você quer combinar um certo intervalo de padrões. Você pode especificar o número inferior e superior de padrões com quantity specifiers
. Os especificadores de quantidade são usados com chaves ( {
e }
). Você coloca dois números entre as chaves - para o número inferior e superior de padrões. Por exemplo, para corresponder apenas a letra a
aparecer entre 3
e 5
vezes na seqüência de "ah"
, o seu regex seria /a{3,5}h/
. deixe A4 = "aaaah";
deixe A2 = "aah";
vamos multipleA = / a {3,5} h /;
multipleA.test (A4); // Retorna true
multipleA.test (A2); // Retorna falso
Instructions
ohRegex
para corresponder apenas de 3
a 6
letras h
na palavra "Oh no"
. Tests
tests:
- text: Seu regex deve usar chaves.
testString: 'assert(ohRegex.source.match(/{.*?}/).length > 0, "Your regex should use curly brackets.");'
- text: Seu regex não deve corresponder a <code>"Ohh no"</code>
testString: 'assert(!ohRegex.test("Ohh no"), "Your regex should not match <code>"Ohh no"</code>");'
- text: Seu regex deve combinar <code>"Ohhh no"</code>
testString: 'assert(ohRegex.test("Ohhh no"), "Your regex should match <code>"Ohhh no"</code>");'
- text: Seu regex deve combinar <code>"Ohhhh no"</code>
testString: 'assert(ohRegex.test("Ohhhh no"), "Your regex should match <code>"Ohhhh no"</code>");'
- text: Seu regex deve combinar <code>"Ohhhhh no"</code>
testString: 'assert(ohRegex.test("Ohhhhh no"), "Your regex should match <code>"Ohhhhh no"</code>");'
- text: Seu regex deve combinar <code>"Ohhhhhh no"</code>
testString: 'assert(ohRegex.test("Ohhhhhh no"), "Your regex should match <code>"Ohhhhhh no"</code>");'
- text: Seu regex não deve corresponder a <code>"Ohhhhhhh no"</code>
testString: 'assert(!ohRegex.test("Ohhhhhhh no"), "Your regex should not match <code>"Ohhhhhhh no"</code>");'
Challenge Seed
let ohStr = "Ohhh no";
let ohRegex = /change/; // Change this line
let result = ohRegex.test(ohStr);
Solution
// solution required