.
The wildcard character .
will match any one character. The wildcard is also called dot
and period
. You can use the wildcard character just like any other character in the regex. For example, if you wanted to match "hug"
, "huh"
, "hut"
, and "hum"
, you can use the regex /hu./
to match all four words.
let humStr = "I'll hum a song";
let hugStr = "Bear hug";
let huRegex = /hu./;
humStr.match(huRegex); // Returns ["hum"]
hugStr.match(huRegex); // Returns ["hug"]
unRegex
so that it matches the strings "run"
, "sun"
, "fun"
, "pun"
, "nun"
, and "bun"
. Your regex should use the wildcard character.
.test()
method.
testString: assert(code.match(/\.test\(.*\)/), 'You should use the .test()
method.');
- text: You should use the wildcard character in your regex unRegex
testString: assert(/\./.test(unRegex.source), 'You should use the wildcard character in your regex unRegex
');
- text: Your regex unRegex
should match "run"
in "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: Your regex unRegex
should match "sun"
in "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: Your regex unRegex
should match "fun"
in "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: Your regex unRegex
should match "pun"
in "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: Your regex unRegex
should match "nun"
in "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: Your regex unRegex
should match "bun"
in "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: Your regex unRegex
should not match "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: Your regex unRegex
should not match "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."
');
```