--- id: 587d7db7367417b2b2512b9d title: Match Beginning String Patterns localeTitle: Emparejar patrones de cuerdas que comienzan challengeType: 1 --- ## Description
Los desafíos anteriores mostraron que las expresiones regulares se pueden usar para buscar una serie de coincidencias. También se utilizan para buscar patrones en posiciones específicas en cadenas. En un desafío anterior, 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 is first and can be found.";
let firstRegex = /^Ricky/;
firstRegex.test(firstString);
// Returns true
let notFirst = "You can't find Ricky now.";
firstRegex.test(notFirst);
// Returns false
## Instructions
Use el carácter de caret en una expresión regular para encontrar "Cal" solo al principio de la cadena rickyAndCal .
## Tests
```yml tests: - text: Su expresión regular debe buscar "Cal" con una letra mayúscula. testString: 'assert(calRegex.source == "^Cal", "Your regex should search for "Cal" 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 "Cal" al principio de la cadena. testString: 'assert(calRegex.test("Cal and Ricky both like racing."), "Your regex should match "Cal" at the beginning of the string.");' - text: Su expresión regular no debe coincidir con "Cal" en medio de una cadena. testString: 'assert(!calRegex.test("Ricky and Cal both like racing."), "Your regex should not match "Cal" in the middle of a string.");' ```
## Challenge Seed
```js let rickyAndCal = "Cal and Ricky both like racing."; let calRegex = /change/; // Change this line let result = calRegex.test(rickyAndCal); ```
## Solution
```js // solution required ```