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