freeCodeCamp/curriculum/challenges/spanish/02-javascript-algorithms-an.../regular-expressions/match-anything-with-wildcar...

5.0 KiB

id title challengeType videoUrl localeTitle
587d7db5367417b2b2512b94 Match Anything with Wildcard Period 1 Coincidir cualquier cosa con el período de comodín

Description

A veces no sabrás (o no necesitarás) los caracteres exactos en tus patrones. Pensar en todas las palabras que coinciden, por ejemplo, una falta de ortografía llevaría mucho tiempo. Por suerte, se puede ahorrar tiempo utilizando el carácter comodín: . El carácter comodín . coincidirá con cualquier personaje. El comodín es también llamado dot y period . Puede usar el carácter comodín como cualquier otro carácter en la expresión regular. Por ejemplo, si desea hacer coincidir "hug" , "huh" , "hut" y "hum" , puede usar la expresión regular /hu./ para hacer coincidir las cuatro palabras.
vamos a humStr = "zumbaré una canción";
dejar hugStr = "abrazo del oso";
deja huRegex = /hu./;
humStr.match (huRegex); // Devuelve ["zumbido"]
hugStr.match (huRegex); // Devoluciones ["abrazo"]

Instructions

Complete la expresión regular unRegex para que coincida con las cadenas "run" , "sun" , "fun" , "pun" , "nun" y "bun" . Su expresión regular debe utilizar el carácter comodín.

Tests

tests:
  - text: Deberías usar el método <code>.test()</code> .
    testString: 'assert(code.match(/\.test\(.*\)/), "You should use the <code>.test()</code> method.");'
  - text: Debe utilizar el carácter comodín en su expresión regular <code>unRegex</code>
    testString: 'assert(/\./.test(unRegex.source), "You should use the wildcard character in your regex <code>unRegex</code>");'
  - text: Su expresión regular <code>unRegex</code> debe coincidir con <code>&quot;run&quot;</code> en <code>&quot;Let us go on a run.&quot;</code>
    testString: 'assert(unRegex.test("Let us go on a run."), "Your regex <code>unRegex</code> should match <code>"run"</code> in <code>"Let us go on a run."</code>");'
  - text: Su expresión regular <code>unRegex</code> debe coincidir con <code>&quot;sun&quot;</code> en <code>&quot;The sun is out today.&quot;</code>
    testString: 'assert(unRegex.test("The sun is out today."), "Your regex <code>unRegex</code> should match <code>"sun"</code> in <code>"The sun is out today."</code>");'
  - text: Su expresión regular <code>unRegex</code> debe coincidir con <code>&quot;fun&quot;</code> en <code>&quot;Coding is a lot of fun.&quot;</code>
    testString: 'assert(unRegex.test("Coding is a lot of fun."), "Your regex <code>unRegex</code> should match <code>"fun"</code> in <code>"Coding is a lot of fun."</code>");'
  - text: Su expresión regular <code>unRegex</code> debe coincidir con <code>&quot;pun&quot;</code> en <code>&quot;Seven days without a pun makes one weak.&quot;</code>
    testString: 'assert(unRegex.test("Seven days without a pun makes one weak."), "Your regex <code>unRegex</code> should match <code>"pun"</code> in <code>"Seven days without a pun makes one weak."</code>");'
  - text: Tu expresión regular <code>unRegex</code> debe coincidir con <code>&quot;nun&quot;</code> en <code>&quot;One takes a vow to be a nun.&quot;</code>
    testString: 'assert(unRegex.test("One takes a vow to be a nun."), "Your regex <code>unRegex</code> should match <code>"nun"</code> in <code>"One takes a vow to be a nun."</code>");'
  - text: Tu regex <code>unRegex</code> debe coincidir con <code>&quot;bun&quot;</code> en <code>&quot;She got fired from the hot dog stand for putting her hair in a bun.&quot;</code>
    testString: 'assert(unRegex.test("She got fired from the hot dog stand for putting her hair in a bun."), "Your regex <code>unRegex</code> should match <code>"bun"</code> in <code>"She got fired from the hot dog stand for putting her hair in a bun."</code>");'
  - text: Su expresión regular <code>unRegex</code> no debe coincidir con <code>&quot;There is a bug in my code.&quot;</code>
    testString: 'assert(!unRegex.test("There is a bug in my code."), "Your regex <code>unRegex</code> should not match <code>"There is a bug in my code."</code>");'
  - text: Tu expresión regular <code>unRegex</code> no debe coincidir con <code>&quot;Catch me if you can.&quot;</code>
    testString: 'assert(!unRegex.test("Can me if you can."), "Your regex <code>unRegex</code> should not match <code>"Catch me if you can."</code>");'

Challenge Seed

let exampleStr = "Let's have fun with regular expressions!";
let unRegex = /change/; // Change this line
let result = unRegex.test(exampleStr);

Solution

// solution required