2.7 KiB
2.7 KiB
id | title | challengeType | videoUrl | localeTitle |
---|---|---|---|---|
587d7db4367417b2b2512b93 | Find More Than the First Match | 1 | العثور على أكثر من المباراة الأولى |
Description
let testStr = "Repeat، Repeat، Repeat"؛للبحث أو استخراج نمط أكثر من مرة ، يمكنك استخدام علم
دع ourRegex = / كرر /؛
testStr.match (ourRegex)؛
// Returns ["Repeat"]
g
. اترك repeatRegex = / Repeat / g؛
testStr.match (repeatRegex)؛
// Returns ["Repeat"، "Repeat"، "Repeat"]
Instructions
starRegex
، ابحث starRegex
الكلمات "Twinkle"
من سلسلة twinkleStar
. ملحوظة يمكنك الحصول على العديد من العلامات على تعديلك مثل
/search/gi
Tests
tests:
- text: يجب أن يستخدم <code>starRegex</code> regex الخاص بك العلم العالمي <code>g</code>
testString: 'assert(starRegex.flags.match(/g/).length == 1, "Your regex <code>starRegex</code> should use the global flag <code>g</code>");'
- text: يجب أن يستخدم <code>starRegex</code> الخاص بك regex <code>starRegex</code> الحالة غير الحساسة <code>i</code>
testString: 'assert(starRegex.flags.match(/i/).length == 1, "Your regex <code>starRegex</code> should use the case insensitive flag <code>i</code>");'
- text: يجب أن تتطابق المطابقة مع كلمتين لكلمة <code>"Twinkle"</code>
testString: 'assert(result.sort().join() == twinkleStar.match(/twinkle/gi).sort().join(), "Your match should match both occurrences of the word <code>"Twinkle"</code>");'
- text: يجب أن تحتوي <code>result</code> المطابقة الخاصة بك على عنصرين.
testString: 'assert(result.length == 2, "Your match <code>result</code> should have two elements in it.");'
Challenge Seed
let twinkleStar = "Twinkle, twinkle, little star";
let starRegex = /change/; // Change this line
let result = twinkleStar; // Change this line
Solution
// solution required