4.2 KiB
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
\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>"The five boxing wizards jump quickly."</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>"Pack my box with five dozen liquor jugs."</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>"How vexingly quick daft zebras jump!"</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>"123 456 7890 ABC def GHI jkl MNO pqr STU vwx YZ."</code> على 36 حرفًا أبجديًا رقميًا في <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, "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