.match()
. Para usar el método .match()
, aplique el método en una cadena y pase la expresión regular dentro de los paréntesis. Aquí hay un ejemplo: "¡Hola, mundo!". Match (/ Hello /);
// Devoluciones ["Hola"]
deja ourStr = "expresiones regulares";
vamos a nuestroRegex = / expresiones /;
ourStr.match (ourRegex);
// Devoluciones ["expresiones"]
.match()
para extraer la coding
palabras. result
debe tener la palabra coding
testString: 'assert(result.join() === "coding", "The result
should have the word coding
");'
- text: Tu regex codingRegex
debería buscar la coding
testString: 'assert(codingRegex.source === "coding", "Your regex codingRegex
should search for coding
");'
- text: Deberías usar el método .match()
.
testString: 'assert(code.match(/\.match\(.*\)/), "You should use the .match()
method.");'
```