freeCodeCamp/curriculum/challenges/arabic/02-javascript-algorithms-an.../regular-expressions/match-ending-string-pattern...

2.4 KiB

id title challengeType videoUrl localeTitle
587d7db7367417b2b2512b9e Match Ending String Patterns 1 تطابق نهاية أنماط سلسلة

Description

في التحدي الأخير ، تعلمت استخدام caret للبحث عن الأنماط في بداية السلاسل. هناك أيضًا طريقة للبحث عن الأنماط في نهاية السلاسل. يمكنك البحث في نهاية السلاسل باستخدام حرف dollar sign $ في نهاية التعليمة regex.
دع theEnding = "هذه قصة لا تنتهي أبدا"؛
let storyRegex = / story $ /؛
storyRegex.test (theEnding)؛
// يعود صحيح
let noEnding = "في بعض الأحيان يجب أن تنتهي القصة" ؛
storyRegex.test (noEnding)؛
// إرجاع خاطئة

Instructions

استخدم حرف الربط ( $ ) لمطابقة السلسلة "caboose" في نهاية سلسلة caboose .

Tests

tests:
  - text: يجب عليك البحث عن <code>&quot;caboose&quot;</code> باستخدام علامة الدولار <code>$</code> anchor في تعبيرك المعتاد.
    testString: 'assert(lastRegex.source == "caboose$", "You should search for <code>"caboose"</code> with the dollar sign <code>$</code> anchor in your regex.");'
  - text: يجب ألا يستخدم تعبيرك المعتاد أي أعلام.
    testString: 'assert(lastRegex.flags == "", "Your regex should not use any flags.");'
  - text: يجب أن تتطابق مع <code>&quot;caboose&quot;</code> في نهاية السلسلة <code>&quot;The last car on a train is the caboose&quot;</code>
    testString: 'assert(lastRegex.test("The last car on a train is the caboose"), "You should match <code>"caboose"</code> at the end of the string <code>"The last car on a train is the caboose"</code>");'

Challenge Seed

let caboose = "The last car on a train is the caboose";
let lastRegex = /change/; // Change this line
let result = lastRegex.test(caboose);

Solution

// solution required