2.1 KiB
2.1 KiB
id, title, challengeType, forumTopicId, localeTitle
id | title | challengeType | forumTopicId | localeTitle |
---|---|---|---|---|
587d7db4367417b2b2512b92 | Extract Matches | 1 | 301340 | Экстракционные матчи |
Description
.match()
. Чтобы использовать метод .match()
, примените метод к строке и передайте в регулярное выражение внутри круглых скобок. Вот пример: «Hello, World!». Match (/ Hello /);
// Возвращает ["Hello"]
let ourStr = "Регулярные выражения";
пусть нашRegex = / выражения /;
ourStr.match (ourRegex);
// Возвращает ["выражения"]
Instructions
.match()
метод , чтобы извлечь слово coding
.
Tests
tests:
- text: The <code>result</code> should have the word <code>coding</code>
testString: assert(result.join() === "coding");
- text: Your regex <code>codingRegex</code> should search for <code>coding</code>
testString: assert(codingRegex.source === "coding");
- text: You should use the <code>.match()</code> method.
testString: assert(code.match(/\.match\(.*\)/));
Challenge Seed
let extractStr = "Extract the word 'coding' from this string.";
let codingRegex = /change/; // Change this line
let result = extractStr; // Change this line
Solution
let extractStr = "Extract the word 'coding' from this string.";
let codingRegex = /coding/; // Change this line
let result = extractStr.match(codingRegex); // Change this line