.match()
. Чтобы использовать метод .match()
, примените метод к строке и передайте в регулярное выражение внутри круглых скобок. Вот пример: «Hello, World!». Match (/ Hello /);
// Возвращает ["Hello"]
let ourStr = "Регулярные выражения";
пусть нашRegex = / выражения /;
ourStr.match (ourRegex);
// Возвращает ["выражения"]
.match()
метод , чтобы извлечь слово coding
. result
должен иметь слово coding
testString: 'assert(result.join() === "coding", "The result
should have the word coding
");'
- text: ''
testString: 'assert(codingRegex.source === "coding", "Your regex codingRegex
should search for coding
");'
- text: ''
testString: 'assert(code.match(/\.match\(.*\)/), "You should use the .match()
method.");'
```