Files
freeCodeCamp/curriculum/challenges/spanish/02-javascript-algorithms-and-data-structures/regular-expressions/specify-exact-number-of-matches.spanish.md
2018-10-08 13:34:43 -04:00

2.7 KiB

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

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 las llaves. Por ejemplo, para hacer coincidir solo la palabra "hah" con la letra a 3 veces, su expresión regular sería /ha{3}h/ .
let A4 = "haaaah";
let A3 = "haaah";
let A100 = "h" + "a".repeat(100) + "h";
let multipleHA = /ha{3}h/;
multipleHA.test(A4); // Returns false
multipleHA.test(A3); // Returns true
multipleHA.test(A100); // Returns false

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: Su expresión regular no debe coincidir con <code class = "notranslate"> "Timber" </code>
    testString: 'assert(!timRegex.test("Timber"), "Your regex should not match <code>"Timber"</code>");'
  - text: Su expresión regular no debe coincidir con <code class = "notranslate"> "Timmber" </code>
    testString: 'assert(!timRegex.test("Timmber"), "Your regex should not match <code>"Timmber"</code>");'
  - text: Su expresión regular no debe coincidir con <code class = "notranslate"> "Timmmber" </code>
    testString: 'assert(!timRegex.test("Timmmber"), "Your regex should not match <code>"Timmmber"</code>");'
  - text: Su expresión regular debe coincidir con <code class = "notranslate"> "Timmmmber" </code>
    testString: 'assert(timRegex.test("Timmmmber"), "Your regex should match <code>"Timmmmber"</code>");'
  - text: Su expresión regular no debe coincidir con <code class = "notranslate"> "Timber" </code> con 30 <code class = "notranslate"> 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