freeCodeCamp/curriculum/challenges/portuguese/02-javascript-algorithms-an.../regular-expressions/specify-upper-and-lower-num...

2.9 KiB
Raw Blame History

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

Lembre-se de usar o sinal de mais + 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

Altere o regex 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>&quot;Ohh no&quot;</code>
    testString: 'assert(!ohRegex.test("Ohh no"), "Your regex should not match <code>"Ohh no"</code>");'
  - text: Seu regex deve combinar <code>&quot;Ohhh no&quot;</code>
    testString: 'assert(ohRegex.test("Ohhh no"), "Your regex should match <code>"Ohhh no"</code>");'
  - text: Seu regex deve combinar <code>&quot;Ohhhh no&quot;</code>
    testString: 'assert(ohRegex.test("Ohhhh no"), "Your regex should match <code>"Ohhhh no"</code>");'
  - text: Seu regex deve combinar <code>&quot;Ohhhhh no&quot;</code>
    testString: 'assert(ohRegex.test("Ohhhhh no"), "Your regex should match <code>"Ohhhhh no"</code>");'
  - text: Seu regex deve combinar <code>&quot;Ohhhhhh no&quot;</code>
    testString: 'assert(ohRegex.test("Ohhhhhh no"), "Your regex should match <code>"Ohhhhhh no"</code>");'
  - text: Seu regex não deve corresponder a <code>&quot;Ohhhhhhh no&quot;</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