5.0 KiB
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
.
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
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>"run"</code> en <code>"Let us go on a run."</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>"sun"</code> en <code>"The sun is out today."</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>"fun"</code> en <code>"Coding is a lot of fun."</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>"pun"</code> en <code>"Seven days without a pun makes one weak."</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>"nun"</code> en <code>"One takes a vow to be a nun."</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>"bun"</code> en <code>"She got fired from the hot dog stand for putting her hair in a bun."</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>"There is a bug in my code."</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>"Catch me if you can."</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