2.5 KiB
2.5 KiB
id, title, challengeType, videoUrl, localeTitle
| id | title | challengeType | videoUrl | localeTitle |
|---|---|---|---|---|
| 587d7db7367417b2b2512b9d | Match Beginning String Patterns | 1 | Emparejar patrones de cuerdas que comienzan |
Description
caret carácter de caret ( ^ ) dentro de un character set para crear un negated character set en la forma [^thingsThatWillNotBeMatched] . Fuera de un character set , el caret se utiliza para buscar patrones al principio de las cadenas. Let firstString = "Ricky es el primero y se puede encontrar.";
Let firstRegex = / ^ Ricky /;
firstRegex.test (firstString);
// Devuelve true
let notFirst = "No puedes encontrar a Ricky ahora.";
firstRegex.test (notFirst);
// Devuelve falso
Instructions
caret en una expresión regular para encontrar "Cal" solo al principio de la cadena rickyAndCal . Tests
tests:
- text: Su expresión regular debe buscar <code>"Cal"</code> con una letra mayúscula.
testString: 'assert(calRegex.source == "^Cal", "Your regex should search for <code>"Cal"</code> with a capital letter.");'
- text: Su expresión regular no debe usar ninguna bandera.
testString: 'assert(calRegex.flags == "", "Your regex should not use any flags.");'
- text: Tu expresión regular debe coincidir con <code>"Cal"</code> al principio de la cadena.
testString: 'assert(calRegex.test("Cal and Ricky both like racing."), "Your regex should match <code>"Cal"</code> at the beginning of the string.");'
- text: Su expresión regular no debe coincidir con <code>"Cal"</code> en medio de una cadena.
testString: 'assert(!calRegex.test("Ricky and Cal both like racing."), "Your regex should not match <code>"Cal"</code> in the middle of a string.");'
Challenge Seed
let rickyAndCal = "Cal and Ricky both like racing.";
let calRegex = /change/; // Change this line
let result = calRegex.test(rickyAndCal);
Solution
// solution required