-
) لمطابقة نطاق من الأحرف على الأحرف. كما يعمل على مطابقة مجموعة من الأرقام. على سبيل المثال ، /[0-5]/
تطابق أي رقم بين 0
و 5
، بما في ذلك 0
و 5
. أيضا ، من الممكن الجمع بين مجموعة من الحروف والأرقام في مجموعة أحرف واحدة. let jennyStr = "Jenny8675309"؛
let myRegex = / [a-z0-9] / ig؛
// تطابق جميع الحروف والأرقام في jennyStr
jennyStr.match (myRegex)؛
h
و s
ومجموعة من الأرقام بين 2
و 6
. تذكر تضمين الأعلام المناسبة في التعابير المنطقية. myRegex
مع 17 عنصرًا.
testString: 'assert(result.length == 17, "Your regex myRegex
should match 17 items.");'
- text: يجب أن يستخدم myRegex
regex العلامة العامة.
testString: 'assert(myRegex.flags.match(/g/).length == 1, "Your regex myRegex
should use the global flag.");'
- text: يجب أن يستخدم myRegex
regex myRegex
حالة الأحرف.
testString: 'assert(myRegex.flags.match(/i/).length == 1, "Your regex myRegex
should use the case insensitive flag.");'
```