Files
freeCodeCamp/curriculum/challenges/russian/02-javascript-algorithms-and-data-structures/regular-expressions/match-characters-that-occur-zero-or-more-times.russian.md

3.2 KiB
Raw Blame History

id, title, challengeType, forumTopicId, localeTitle
id title challengeType forumTopicId localeTitle
587d7db6367417b2b2512b9a Match Characters that Occur Zero or More Times 1 301351 Символы соответствия, которые имеют нулевой или более длительный период

Description

Последний вызов использовал знак плюс + для поиска символов, которые происходят один или несколько раз. Также есть опция, которая соответствует символам, которые появляются ноль или более раз. Характер для этого - asterisk или star : * .
let soccerWord = "gooooooooal!";
пусть gPhrase = «чувство кишки»;
пусть oPhrase = "над луной";
let goRegex = / go * /;
soccerWord.match (goRegex); // Возвращает ["goooooooo"]
gPhrase.match (goRegex); // Возвращает ["g"]
oPhrase.match (goRegex); // Возвращает значение null

Instructions

Создайте regex chewieRegex который использует символ * чтобы соответствовать всем верхним и нижним символам "a" в chewieQuote . Вашему регулярному выражению не нужны флаги, и он не должен совпадать с какими-либо другими цитатами.

Tests

tests:
  - text: Your regex <code>chewieRegex</code> should use the <code>*</code> character to match zero or more <code>a</code> characters.
    testString: assert(/\*/.test(chewieRegex.source));
  - text: Your regex should match <code>"A"</code> in <code>chewieQuote</code>.
    testString: assert(result[0][0] === 'A');
  - text: Your regex should match <code>"Aaaaaaaaaaaaaaaa"</code> in <code>chewieQuote</code>.
    testString: assert(result[0] === 'Aaaaaaaaaaaaaaaa');
  - text: Your regex <code>chewieRegex</code> should match 16 characters in <code>chewieQuote</code>.
    testString: assert(result[0].length === 16);
  - text: Your regex should not match any characters in "He made a fair move. Screaming about it can't help you."
    testString: assert(!"He made a fair move. Screaming about it can't help you.".match(chewieRegex));
  - text: Your regex should not match any characters in "Let him have it. It's not wise to upset a Wookiee."
    testString: assert(!"Let him have it. It's not wise to upset a Wookiee.".match(chewieRegex));

Challenge Seed

let chewieRegex = /change/; // Only change this line
let result = chewieQuote.match(chewieRegex);

Before Tests

const chewieQuote = "Aaaaaaaaaaaaaaaarrrgh!";

Solution

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