2.3 KiB
2.3 KiB
id | title | challengeType | videoUrl | localeTitle |
---|---|---|---|---|
587d7db3367417b2b2512b8f | Match Literal Strings | 1 | Combinar cordas literais |
Description
"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
Instructions
waldoRegex
para encontrar "Waldo"
na string waldoIsHiding
com uma correspondência literal. Tests
tests:
- text: Seu regex <code>waldoRegex</code> deve encontrar <code>"Waldo"</code>
testString: 'assert(waldoRegex.test(waldoIsHiding), "Your regex <code>waldoRegex</code> should find <code>"Waldo"</code>");'
- text: Seu regex <code>waldoRegex</code> não deve procurar por mais nada.
testString: 'assert(!waldoRegex.test("Somewhere is hiding in this text."), "Your regex <code>waldoRegex</code> 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.");'
Challenge Seed
let waldoIsHiding = "Somewhere Waldo is hiding in this text.";
let waldoRegex = /search/; // Change this line
let result = waldoRegex.test(waldoIsHiding);
Solution
// solution required