freeCodeCamp/curriculum/challenges/arabic/02-javascript-algorithms-an.../regular-expressions/match-all-letters-and-numbe...

4.2 KiB

id title challengeType videoUrl localeTitle
587d7db7367417b2b2512b9f Match All Letters and Numbers 1 المباراة جميع الحروف والأرقام

Description

باستخدام فئات الأحرف ، تمكنت من البحث عن جميع حروف الأبجدية باستخدام [az] . هذا النوع من فئة الأحرف شائع بما فيه الكفاية أن هناك اختصارًا له ، على الرغم من أنه يتضمن بضعة أحرف إضافية أيضًا. إن أقرب فئة أحرف في JavaScript لتطابق الأبجدية هي \w . هذا الاختصار يساوي [A-Za-z0-9_] . فئة الأحرف هذا تطابق الأحرف الكبيرة والصغيرة بالإضافة إلى الأرقام. ملاحظة ، يتضمن فئة الأحرف هذه أيضًا حرف تسطير أسفل السطر ( _ ).
let longHand = / [A-Za-z0-9 _] + /؛
اترك shortHand = / \ w + /؛
السماح للأرقام = "42" ؛
السماح varNames = "important_var" ؛
longHand.test (الأرقام)؛ // يعود صحيح
shortHand.test (الأرقام)؛ // يعود صحيح
longHand.test (varNames)؛ // يعود صحيح
shortHand.test (varNames)؛ // يعود صحيح
ومن المعروف أيضا أن هذه الفئات طابع الاختصار كما shorthand character classes .

Instructions

استخدم class \w حرف الاختصار لحساب عدد الأحرف الأبجدية الرقمية في علامات الاقتباس والسلاسل المختلفة.

Tests

tests:
  - text: يجب أن يستخدم تعبيرك العادي العلم العام.
    testString: 'assert(alphabetRegexV2.global, "Your regex should use the global flag.");'
  - text: يجب أن يستخدم تعبيرك العادي الحرف المختصر
    testString: 'assert(/\\w/.test(alphabetRegexV2.source), "Your regex should use the shorthand character <code>\w</code> to match all characters which are alphanumeric.");'
  - text: يجب أن يعثر تعبيرك المنطقي على 31 حرفًا أبجديًا رقميًا في <code>&quot;The five boxing wizards jump quickly.&quot;</code>
    testString: 'assert("The five boxing wizards jump quickly.".match(alphabetRegexV2).length === 31, "Your regex should find 31 alphanumeric characters in <code>"The five boxing wizards jump quickly."</code>");'
  - text: يجب أن يعثر تعبيرك المنطقي على 32 حرفًا أبجديًا رقميًا في <code>&quot;Pack my box with five dozen liquor jugs.&quot;</code>
    testString: 'assert("Pack my box with five dozen liquor jugs.".match(alphabetRegexV2).length === 32, "Your regex should find 32 alphanumeric characters in <code>"Pack my box with five dozen liquor jugs."</code>");'
  - text: يجب أن يعثر تعبيرك المعتاد على 30 حرفًا أبجديًا رقميًا في <code>&quot;How vexingly quick daft zebras jump!&quot;</code>
    testString: 'assert("How vexingly quick daft zebras jump!".match(alphabetRegexV2).length === 30, "Your regex should find 30 alphanumeric characters in <code>"How vexingly quick daft zebras jump!"</code>");'
  - text: يجب أن يعثر <code>&quot;123 456 7890 ABC def GHI jkl MNO pqr STU vwx YZ.&quot;</code> على 36 حرفًا أبجديًا رقميًا في <code>&quot;123 456 7890 ABC def GHI jkl MNO pqr STU vwx YZ.&quot;</code>
    testString: 'assert("123 456 7890 ABC def GHI jkl MNO pqr STU vwx YZ.".match(alphabetRegexV2).length === 36, "Your regex should find 36 alphanumeric characters in <code>"123 456 7890 ABC def GHI jkl MNO pqr STU vwx YZ."</code>");'

Challenge Seed

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

Solution

// solution required