mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-01-24 06:03:28 -05:00
1.8 KiB
1.8 KiB
id, title, challengeType, forumTopicId, dashedName
| id | title | challengeType | forumTopicId | dashedName |
|---|---|---|---|---|
| 587d7db7367417b2b2512b9e | Match Ending String Patterns | 1 | 301352 | match-ending-string-patterns |
--description--
في التحدي الأخير، تعلمت استخدام رمز الـ caret للبحث عن أنماط في بداية ال strings. وهناك أيضا طريقة للبحث عن أنماط في نهاية ال strings.
يمكنك البحث في نهاية ال strings باستخدام رمز إشارة الدولار $ في نهاية الـ regex.
let theEnding = "This is a never ending story";
let storyRegex = /story$/;
storyRegex.test(theEnding);
let noEnding = "Sometimes a story will have to end";
storyRegex.test(noEnding);
أول استدعاء لـ test سيعيد true والثاني سيعيد false.
--instructions--
استخدم رمز الدولار ($) لمطابقة المقطع النصي caboose في نهاية caboose.
--hints--
يجب عليك البحث عن caboose باستخدام علامة الدولار $ في نمط regex.
assert(lastRegex.source == 'caboose$');
لا يجب أن يستخدم الـ regex الخاص بك أي flags.
assert(lastRegex.flags == '');
يجب عليك مطابقة caboose في نهاية السلسلة The last car on a train is the caboose
lastRegex.lastIndex = 0;
assert(lastRegex.test('The last car on a train is the caboose'));
--seed--
--seed-contents--
let caboose = "The last car on a train is the caboose";
let lastRegex = /change/; // Change this line
let result = lastRegex.test(caboose);
--solutions--
let caboose = "The last car on a train is the caboose";
let lastRegex = /caboose$/; // Change this line
let result = lastRegex.test(caboose);