.
O caractere curinga .
irá corresponder a qualquer caractere. O curinga também é chamado de dot
e period
. Você pode usar o caractere curinga como qualquer outro caractere na regex. Por exemplo, se você quisesse combinar "hug"
, "huh"
, "hut"
e "hum"
, você pode usar o regex /hu./
para combinar todas as quatro palavras. humStr = "Vou cantarolar uma canção";
deixe hugStr = "Bear hug";
vamos huRegex = /hu./;
humStr.match (huRegex); // Retorna ["hum"]
hugStr.match (huRegex); // Retorna ["abraço"]
unRegex
para que ele corresponda às strings "run"
, "sun"
, "fun"
, "pun"
, "nun"
e "bun"
. Seu regex deve usar o caractere curinga. .test()
.
testString: 'assert(code.match(/\.test\(.*\)/), "You should use the .test()
method.");'
- text: Você deve usar o caractere curinga em seu regex unRegex
testString: 'assert(/\./.test(unRegex.source), "You should use the wildcard character in your regex unRegex
");'
- text: Seu regex unRegex
deve combinar "run"
em "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: Seu regex unRegex
deve combinar "sun"
em "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: Seu regex unRegex
deve combinar "fun"
em "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: Seu regex unRegex
deve combinar "pun"
em "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: Seu regex unRegex
deve corresponder a "nun"
em "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: Seu regex unRegex
deve coincidir com "bun"
em "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: Seu regex unRegex
não deve corresponder "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: Seu regex unRegex
não deve coincidir com "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."
");'
```