--- id: 587d7db7367417b2b2512b9d title: Match Beginning String Patterns challengeType: 1 videoUrl: '' localeTitle: Combinar Padrões de Cordas Iniciais --- ## Description
Desafios anteriores mostraram que expressões regulares podem ser usadas para procurar um número de correspondências. Eles também são usados ​​para procurar padrões em posições específicas em strings. Em um desafio anterior, você usou o caractere caret ( ^ ) dentro de um character set para criar um negated character set no formato [^thingsThatWillNotBeMatched] . Fora de um character set , o caret é usado para procurar padrões no início das seqüências de caracteres.
deixe firstString = "Ricky é o primeiro e pode ser encontrado";
deixe firstRegex = / ^ Ricky /;
firstRegex.test (firstString);
// Retorna true
vamos notFirst = "Você não pode encontrar Ricky agora.";
firstRegex.test (notFirst);
// Retorna falso
## Instructions
Use o caractere de caret em um regex para localizar "Cal" apenas no início da string rickyAndCal .
## Tests
```yml tests: - text: Seu regex deve procurar por "Cal" com uma letra maiúscula. testString: 'assert(calRegex.source == "^Cal", "Your regex should search for "Cal" with a capital letter.");' - text: Seu regex não deve usar sinalizadores. testString: 'assert(calRegex.flags == "", "Your regex should not use any flags.");' - text: Seu regex deve corresponder a "Cal" no início da string. testString: 'assert(calRegex.test("Cal and Ricky both like racing."), "Your regex should match "Cal" at the beginning of the string.");' - text: Seu regex não deve corresponder a "Cal" no meio de uma string. 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 ```