Files

2.5 KiB

id, title, challengeType, forumTopicId, dashedName
id title challengeType forumTopicId dashedName
587d7db6367417b2b2512b9a Haz coincidir caracteres que aparecen cero o más veces 1 301351 match-characters-that-occur-zero-or-more-times

--description--

El último desafío utilizó el signo más + para buscar caracteres que aparecen una o más veces. También hay una opción para hacer coincidir caracteres que aparecen cero o más veces.

El carácter que hace esto es el asterisco o la estrella: *.

let soccerWord = "gooooooooal!";
let gPhrase = "gut feeling";
let oPhrase = "over the moon";
let goRegex = /go*/;
soccerWord.match(goRegex);
gPhrase.match(goRegex);
oPhrase.match(goRegex);

En orden, los tres match devolverán los valores ["goooooooo"], ["g"], y null.

--instructions--

Para este desafío, chewieQuote ha sido inicializada entre bastidores con la cadena Aaaaaaaaaaaaaaaarrrgh!. Crea una expresión regular chewieRegex que utilice el carácter * para encontrar el carácter A mayúscula seguido inmediatamente por cero o más caracteres a minúscula en chewieQuote. Tu expresión regular no necesita banderas o clases de caracteres, y no debe coincidir con ninguna de las otras comillas.

--hints--

Tu expresión regular chewieRegex debe utilizar el * para que coincida con cero o más caracteres a.

assert(/\*/.test(chewieRegex.source));

Tu expresión regular debe coincidir con la cadena A en chewieQuote.

assert(result[0][0] === 'A');

Tu expresión regular debe coincidir con la cadena Aaaaaaaaaaaaaaaa en chewieQuote.

assert(result[0] === 'Aaaaaaaaaaaaaaaa');

Tu expresión regular chewieRegex debe coincidir con 16 caracteres en chewieQuote.

assert(result[0].length === 16);

Tu regex no debe coincidir con ningún carácter en la cadena He made a fair move. Screaming about it can't help you.

assert(
  !"He made a fair move. Screaming about it can't help you.".match(chewieRegex)
);

Tu regex no debe coincidir con ningún carácter en la cadena Let him have it. It's not wise to upset a Wookiee.

assert(
  !"Let him have it. It's not wise to upset a Wookiee.".match(chewieRegex)
);

--seed--

--before-user-code--

const chewieQuote = "Aaaaaaaaaaaaaaaarrrgh!";

--seed-contents--

// Only change code below this line
let chewieRegex = /change/; // Change this line
// Only change code above this line

let result = chewieQuote.match(chewieRegex);

--solutions--

  let chewieRegex = /Aa*/;
  let result = chewieQuote.match(chewieRegex);