. Символ подстановки . будет соответствовать любому персонажу. Подстановочный знак также называется dot и period . Вы можете использовать подстановочный знак, как и любой другой символ в регулярном выражении. Например, если вы хотите совместить "hug" , "huh" , "hut" и "hum" , вы можете использовать regex /hu./ для соответствия всем четырем словам. пусть humStr = «Я буду напевать песню»;
let hugStr = «Обнимать медведя»;
пусть huRegex = /hu./;
humStr.match (huRegex); // Возвращает ["гул"]
hugStr.match (huRegex); // Возвращает ["hug"]
unRegex так, чтобы он соответствовал строкам "run" , "sun" , "fun" , "pun" , "nun" и "bun" . В вашем регулярном выражении должен использоваться символ подстановки. .test() .
testString: 'assert(code.match(/\.test\(.*\)/), "You should use the .test() method.");'
- text: Вы должны использовать символ подстановки в своем регулярном выражении unRegex
testString: 'assert(/\./.test(unRegex.source), "You should use the wildcard character in your regex unRegex");'
- text: ''
testString: 'assert(unRegex.test("Let us go on a run."), "Your regex unRegex should match "run" in "Let us go on a run."");'
- text: ''
testString: 'assert(unRegex.test("The sun is out today."), "Your regex unRegex should match "sun" in "The sun is out today."");'
- text: ''
testString: 'assert(unRegex.test("Coding is a lot of fun."), "Your regex unRegex should match "fun" in "Coding is a lot of fun."");'
- text: ''
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: ''
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: ''
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: ''
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: ''
testString: 'assert(!unRegex.test("Can me if you can."), "Your regex unRegex should not match "Catch me if you can."");'
```