2.3 KiB
2.3 KiB
id, title, challengeType, videoUrl, localeTitle
| id | title | challengeType | videoUrl | localeTitle |
|---|---|---|---|---|
| 587d7db3367417b2b2512b8f | Match Literal Strings | 1 | Unir cuerdas literales |
Description
"Hello" usando la expresión regular /Hello/ . Esa expresión regular buscó una coincidencia literal de la cadena "Hello" . Aquí hay otro ejemplo que busca una coincidencia literal de la cadena "Kevin" : let testStr = "Hola, mi nombre es Kevin.";Cualquier otra forma de
vamos a testRegex = / Kevin /;
testRegex.test (testStr);
// Devuelve true
"Kevin" no coincidirá. Por ejemplo, la expresión regular /Kevin/ no coincidirá con "kevin" o "KEVIN" . dejar wrongRegex = / kevin /;Un desafío futuro mostrará cómo emparejar esas otras formas también.
wrongRegex.test (testStr);
// Devuelve falso
Instructions
waldoRegex para encontrar "Waldo" en la cadena waldoIsHiding con una coincidencia literal. Tests
tests:
- text: Tu regex <code>waldoRegex</code> debería encontrar <code>"Waldo"</code>
testString: 'assert(waldoRegex.test(waldoIsHiding), "Your regex <code>waldoRegex</code> should find <code>"Waldo"</code>");'
- text: Su regex <code>waldoRegex</code> no debe buscar nada más.
testString: 'assert(!waldoRegex.test("Somewhere is hiding in this text."), "Your regex <code>waldoRegex</code> should not search for anything else.");'
- text: Debe realizar una coincidencia de cadena literal con su expresión regular.
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