Files
freeCodeCamp/curriculum/challenges/russian/02-javascript-algorithms-and-data-structures/regular-expressions/match-all-letters-and-numbers.russian.md

3.7 KiB
Raw Blame History

id, title, challengeType, forumTopicId, localeTitle
id title challengeType forumTopicId localeTitle
587d7db7367417b2b2512b9f Match All Letters and Numbers 1 301346 Совпадение всех букв и цифр

Description

Используя классы символов, вы смогли найти все буквы алфавита с помощью [az] . Такой класс символов достаточно распространен, что есть ярлык для него, хотя он включает и несколько дополнительных символов. Самый близкий класс символов в JavaScript для соответствия алфавиту - \w . Этот ярлык равен [A-Za-z0-9_] . Этот класс символов соответствует буквам верхнего и нижнего регистра плюс номерам. Обратите внимание: этот класс символов также включает символ подчеркивания ( _ ).
пусть longHand = / [A-Za-z0-9 _] + /;
пусть shortHand = / \ w + /;
пусть числа = «42»;
пусть varNames = "important_var";
longHand.test (номера); // Возвращает true
shortHand.test (номера); // Возвращает true
longHand.test (имя переменный); // Возвращает true
shortHand.test (имя переменный); // Возвращает true
Эти классы ярлыков символов также известны как shorthand character classes .

Instructions

Используйте класс символьных символов \w чтобы подсчитать количество буквенно-цифровых символов в разных кавычках и строках.

Tests

tests:
  - text: Your regex should use the global flag.
    testString: assert(alphabetRegexV2.global);
  - text: Your regex should use the shorthand character <code>\w</code> to match all characters which are alphanumeric.
    testString: assert(/\\w/.test(alphabetRegexV2.source));
  - text: Your regex should find 31 alphanumeric characters in <code>"The five boxing wizards jump quickly."</code>
    testString: assert("The five boxing wizards jump quickly.".match(alphabetRegexV2).length === 31);
  - text: Your regex should find 32 alphanumeric characters in <code>"Pack my box with five dozen liquor jugs."</code>
    testString: assert("Pack my box with five dozen liquor jugs.".match(alphabetRegexV2).length === 32);
  - text: Your regex should find 30 alphanumeric characters in <code>"How vexingly quick daft zebras jump!"</code>
    testString: assert("How vexingly quick daft zebras jump!".match(alphabetRegexV2).length === 30);
  - text: Your regex should find 36 alphanumeric characters in <code>"123 456 7890 ABC def GHI jkl MNO pqr STU vwx YZ."</code>
    testString: assert("123 456 7890 ABC def GHI jkl MNO pqr STU vwx YZ.".match(alphabetRegexV2).length === 36);

Challenge Seed

let quoteSample = "The five boxing wizards jump quickly.";
let alphabetRegexV2 = /change/; // Change this line
let result = quoteSample.match(alphabetRegexV2).length;

Solution

let quoteSample = "The five boxing wizards jump quickly.";
let alphabetRegexV2 = /\w/g; // Change this line
let result = quoteSample.match(alphabetRegexV2).length;