.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"]
.match()
para extrair a coding
palavras. result
deve ter a palavra coding
testString: 'assert(result.join() === "coding", "The result
should have the word coding
");'
- text: Seu regex codingRegex
deve procurar por coding
testString: 'assert(codingRegex.source === "coding", "Your regex codingRegex
should search for coding
");'
- text: Você deve usar o método .match()
.
testString: 'assert(code.match(/\.match\(.*\)/), "You should use the .match()
method.");'
```