"Hello"
usando a expressão regular /Hello/
. Essa regex procurou por uma correspondência literal da string "Hello"
. Aqui está outro exemplo em busca de uma correspondência literal da string "Kevin"
: deixe testStr = "Olá, meu nome é Kevin.";Qualquer outra forma de
deixe testRegex = / Kevin /;
testRegex.test (testStr);
// Retorna true
"Kevin"
não será igual. Por exemplo, o regex /Kevin/
não coincidirá com "kevin"
ou "KEVIN"
. vamos wrongRegex = / kevin /;Um desafio futuro mostrará como combinar esses outros formulários também.
wrongRegex.test (testStr);
// Retorna falso
waldoRegex
para encontrar "Waldo"
na string waldoIsHiding
com uma correspondência literal. waldoRegex
deve encontrar "Waldo"
testString: 'assert(waldoRegex.test(waldoIsHiding), "Your regex waldoRegex
should find "Waldo"
");'
- text: Seu regex waldoRegex
não deve procurar por mais nada.
testString: 'assert(!waldoRegex.test("Somewhere is hiding in this text."), "Your regex waldoRegex
should not search for anything else.");'
- text: Você deve executar uma correspondência literal de string com sua regex.
testString: 'assert(!/\/.*\/i/.test(code), "You should perform a literal string match with your regex.");'
```