2.8 KiB
2.8 KiB
id, title, challengeType, videoUrl, localeTitle
| id | title | challengeType | videoUrl | localeTitle |
|---|---|---|---|---|
| 587d7db7367417b2b2512b9d | Match Beginning String Patterns | 1 | مباراة بداية أنماط سلسلة |
Description
caret ( ^ ) داخل مجموعة character set لإنشاء مجموعة negated character set [^thingsThatWillNotBeMatched] في النموذج [^thingsThatWillNotBeMatched] . خارج مجموعة character set ، يتم استخدام caret للبحث عن الأنماط في بداية السلاسل. let firstString = "Ricky is first and can be found."؛
let firstRegex = / ^ Ricky /؛
firstRegex.test (firstString)؛
// يعود صحيح
let notFirst = "لا يمكنك العثور على Ricky الآن."؛
firstRegex.test (notFirst)؛
// إرجاع خاطئة
Instructions
caret في تعبير منطقي للبحث عن "Cal" فقط في بداية السلسلة rickyAndCal . Tests
tests:
- text: يجب أن يبحث التعبير المعتاد عن <code>"Cal"</code> بحرف كبير.
testString: 'assert(calRegex.source == "^Cal", "Your regex should search for <code>"Cal"</code> with a capital letter.");'
- text: يجب ألا يستخدم تعبيرك المعتاد أي أعلام.
testString: 'assert(calRegex.flags == "", "Your regex should not use any flags.");'
- text: يجب أن يتطابق تعبيرك العادي مع كلمة <code>"Cal"</code> في بداية السلسلة.
testString: 'assert(calRegex.test("Cal and Ricky both like racing."), "Your regex should match <code>"Cal"</code> at the beginning of the string.");'
- text: يجب ألا يتطابق التعبير العادي مع <code>"Cal"</code> في وسط سلسلة.
testString: 'assert(!calRegex.test("Ricky and Cal both like racing."), "Your regex should not match <code>"Cal"</code> in the middle of a string.");'
Challenge Seed
let rickyAndCal = "Cal and Ricky both like racing.";
let calRegex = /change/; // Change this line
let result = calRegex.test(rickyAndCal);
Solution
// solution required