freeCodeCamp/curriculum/challenges/spanish/02-javascript-algorithms-an.../regular-expressions/specify-exact-number-of-mat...

2.8 KiB
Raw Blame History

id title challengeType videoUrl localeTitle
587d7db9367417b2b2512ba7 Specify Exact Number of Matches 1 Especifique el número exacto de coincidencias

Description

Puede especificar el número inferior y superior de patrones con quantity specifiers utilizando llaves. A veces solo quieres un número específico de coincidencias. Para especificar un cierto número de patrones, solo tiene ese número entre los corchetes. Por ejemplo, para hacer coincidir solo la palabra "hah" con la letra a 3 veces, su expresión regular sería /ha{3}h/ .
sea A4 = "haaaah";
sea A3 = "haaah";
deje A100 = "h" + "a" .repeat (100) + "h";
sea multipleHA = / ha {3} h /;
multipleHA.test (A4); // Devuelve falso
prueba de prueba múltiple (A3); // Devuelve true
prueba de prueba múltiple (A100); // Devuelve falso

Instructions

Cambie el regex timRegex para que coincida con la palabra "Timber" solo cuando tenga cuatro letras m .

Tests

tests:
  - text: Su expresión regular debe utilizar llaves.
    testString: 'assert(timRegex.source.match(/{.*?}/).length > 0, "Your regex should use curly brackets.");'
  - text: Tu expresión regular no debe coincidir con <code>&quot;Timber&quot;</code>
    testString: 'assert(!timRegex.test("Timber"), "Your regex should not match <code>"Timber"</code>");'
  - text: Tu expresión regular no debe coincidir con <code>&quot;Timmber&quot;</code>
    testString: 'assert(!timRegex.test("Timmber"), "Your regex should not match <code>"Timmber"</code>");'
  - text: Tu expresión regular no debe coincidir con <code>&quot;Timmmber&quot;</code>
    testString: 'assert(!timRegex.test("Timmmber"), "Your regex should not match <code>"Timmmber"</code>");'
  - text: Tu expresión regular debe coincidir con <code>&quot;Timmmmber&quot;</code>
    testString: 'assert(timRegex.test("Timmmmber"), "Your regex should match <code>"Timmmmber"</code>");'
  - text: Su expresión regular no debe coincidir con <code>&quot;Timber&quot;</code> con 30 <code>m</code> en ella.
    testString: 'assert(!timRegex.test("Ti" + "m".repeat(30) + "ber"), "Your regex should not match <code>"Timber"</code> with 30 <code>m</code>\"s in it.");'

Challenge Seed

let timStr = "Timmmmber";
let timRegex = /change/; // Change this line
let result = timRegex.test(timStr);

Solution

// solution required