1.9 KiB
1.9 KiB
id | title | challengeType | videoUrl | localeTitle |
---|---|---|---|---|
587d7db4367417b2b2512b92 | Extract Matches | 1 | Extrair correspondências |
Description
.match()
. Para usar o método .match()
, aplique o método em uma string e passe o regex dentro dos parênteses. Aqui está um exemplo: "Olá, mundo!". Match (/ Hello /);
// Retorna ["Olá"]
vamos ourStr = "Expressões regulares";
vamos ourRegex = / expressões /;
ourStr.match (ourRegex);
// Retorna ["expressões"]
Instructions
.match()
para extrair a coding
palavras. Tests
tests:
- text: O <code>result</code> deve ter a palavra <code>coding</code>
testString: 'assert(result.join() === "coding", "The <code>result</code> should have the word <code>coding</code>");'
- text: Seu regex <code>codingRegex</code> deve procurar por <code>coding</code>
testString: 'assert(codingRegex.source === "coding", "Your regex <code>codingRegex</code> should search for <code>coding</code>");'
- text: Você deve usar o método <code>.match()</code> .
testString: 'assert(code.match(/\.match\(.*\)/), "You should use the <code>.match()</code> method.");'
Challenge Seed
let extractStr = "Extract the word 'coding' from this string.";
let codingRegex = /change/; // Change this line
let result = extractStr; // Change this line
Solution
// solution required