3.7 KiB
3.7 KiB
id | title | challengeType | videoUrl | localeTitle |
---|---|---|---|---|
587d7db5367417b2b2512b95 | Match Single Character with Multiple Possibilities | 1 | تطابق شخصية واحدة مع إمكانيات متعددة |
Description
/literal/
) وحرف البدل ( /./
). هذه هي الحدود القصوى للتعبيرات العادية ، حيث يجد المرء مباريات متطابقة ويطابق الآخر كل شيء. هناك خيارات توازن بين النقيضين. يمكنك البحث عن نمط حرفية مع بعض المرونة مع character classes
. تتيح لك فئات الأحرف تعريف مجموعة من الأحرف التي ترغب في مطابقتها بوضعها داخل أقواس مربعة ( [
و ]
). على سبيل المثال ، تريد مطابقة "bag"
و "big"
و "bug"
وليس "bog"
. يمكنك إنشاء regex /b[aiu]g/
للقيام بذلك. إن [aiu]
هو فئة الشخصية التي تتطابق فقط مع الأحرف "a"
أو "i"
أو "u"
. let bigStr = "big"؛
اسمحوا bagStr = "حقيبة" ؛
let bugStr = "bug"؛
let bogStr = "bog"؛
let bgRegex = / b [aiu] g /؛
bigStr.match (bgRegex)؛ // Returns ["big"]
bagStr.match (bgRegex)؛ // Returns ["bag"]
bugStr.match (bgRegex)؛ // Returns ["bug"]
bogStr.match (bgRegex)؛ // يعود لاغيا
Instructions
a
، e
، i
، o
، u
) في your regex vowelRegex
للعثور على جميع حروف العلة في سلسلة quoteSample
. ملحوظة تأكد من مطابقة حروف العلة العلوية والصغيرة.
Tests
tests:
- text: يجب أن تجد كل الحروف المتحركة 25.
testString: 'assert(result.length == 25, "You should find all 25 vowels.");'
- text: يجب أن يستخدم regex <code>vowelRegex</code> فئة شخصية.
testString: 'assert(/\[.*\]/.test(vowelRegex.source), "Your regex <code>vowelRegex</code> should use a character class.");'
- text: يجب أن يستخدم regex <code>vowelRegex</code> العلم العام.
testString: 'assert(vowelRegex.flags.match(/g/).length == 1, "Your regex <code>vowelRegex</code> should use the global flag.");'
- text: يجب أن يستخدم <code>vowelRegex</code> regex <code>vowelRegex</code> علم حالة الأحرف.
testString: 'assert(vowelRegex.flags.match(/i/).length == 1, "Your regex <code>vowelRegex</code> should use the case insensitive flag.");'
- text: يجب ألا يطابق تعبيرك المعتاد أي أحرف ساكنة.
testString: 'assert(!/[b-df-hj-np-tv-z]/gi.test(result.join()), "Your regex should not match any consonants.");'
Challenge Seed
let quoteSample = "Beware of bugs in the above code; I have only proved it correct, not tried it.";
let vowelRegex = /change/; // Change this line
let result = vowelRegex; // Change this line
Solution
// solution required