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

3.3 KiB
Raw Blame History

id, title, challengeType, forumTopicId, localeTitle
id title challengeType forumTopicId localeTitle
587d7db8367417b2b2512ba0 Match Everything But Letters and Numbers 1 301353 Совсем все, кроме букв и цифр

Description

Вы узнали, что вы можете использовать ярлык для соответствия буквенно-цифровым [A-Za-z0-9_] с помощью \w . Естественным шаблоном, который вы, возможно, захотите найти, является противоположность буквенно-цифровых символов. Вы можете искать противоположное \w с \W Обратите внимание, что противоположный шаблон использует заглавную букву. Этот ярлык совпадает с [^A-Za-z0-9_] .
пусть shortHand = / \ W /;
пусть числа = «42%»;
пусть предложение = «Кодирование!»;
numbers.match (стенографии); // Возвращает ["%"]
sentence.match (стенографии); // Возвращает ["!"]

Instructions

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

Tests

tests:
  - text: Your regex should use the global flag.
    testString: assert(nonAlphabetRegex.global);
  - text: Your regex should find 6 non-alphanumeric characters in <code>"The five boxing wizards jump quickly."</code>.
    testString: assert("The five boxing wizards jump quickly.".match(nonAlphabetRegex).length == 6);
  - text: Your regex should use the shorthand character to match characters which are non-alphanumeric.
    testString: assert(/\\W/.test(nonAlphabetRegex.source));
  - text: Your regex should find 8 non-alphanumeric characters in <code>"Pack my box with five dozen liquor jugs."</code>
    testString: assert("Pack my box with five dozen liquor jugs.".match(nonAlphabetRegex).length == 8);
  - text: Your regex should find 6 non-alphanumeric characters in <code>"How vexingly quick daft zebras jump!"</code>
    testString: assert("How vexingly quick daft zebras jump!".match(nonAlphabetRegex).length == 6);
  - text: Your regex should find 12 non-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(nonAlphabetRegex).length == 12);

Challenge Seed

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

Solution

let quoteSample = "The five boxing wizards_jump quickly.";
let nonAlphabetRegex = /\W/g; // Change this line
let result = quoteSample.match(nonAlphabetRegex).length;