freeCodeCamp/curriculum/challenges/arabic/02-javascript-algorithms-an.../regular-expressions/match-characters-that-occur...

3.0 KiB

id title challengeType videoUrl localeTitle
587d7db6367417b2b2512b99 Match Characters that Occur One or More Times 1 مطابقة الأحرف التي تحدث مرة واحدة أو أكثر

Description

في بعض الأحيان ، تحتاج إلى مطابقة حرف (أو مجموعة من الأحرف) التي تظهر مرة واحدة أو أكثر في صف واحد. هذا يعني أنه يحدث مرة واحدة على الأقل ، ويمكن أن يتكرر. يمكنك استخدام + للتحقق مما إذا كانت هذه هي الحالة. تذكر ، يجب أن تكون الشخصية أو النمط موجودًا على التوالي. بمعنى ، يجب على الحرف تكرار واحد بعد الآخر. على سبيل المثال ، سيعثر /a+/g على تطابق واحد في "abc" وإرجاع ["a"] . نظرًا لوجود + ، سيجد أيضًا تطابقًا واحدًا في "aabc" وإرجاع ["aa"] . لو كانت بدلا التحقق من سلسلة "abab" ، فإنه يجد مباراتين والعودة ["a", "a"] لأن a الأحرف ليست في صف واحد - هناك b بينهما. أخيرًا ، نظرًا لعدم وجود "a" في السلسلة "bcd" ، فلن تجد تطابقًا.

Instructions

تريد البحث عن تطابقات عندما يحدث الحرف s مرة أو أكثر في "Mississippi" . اكتب regex يستخدم علامة + .

Tests

tests:
  - text: التعابير المنطقية الخاصة بك <code>myRegex</code> يجب استخدام <code>+</code> إشارة لمباراة واحدة أو أكثر من <code>s</code> حرفا.
    testString: 'assert(/\+/.test(myRegex.source), "Your regex <code>myRegex</code> should use the <code>+</code> sign to match one or more <code>s</code> characters.");'
  - text: يجب أن يتطابق التعبير العادي مع <code>myRegex</code> مع عنصرين.
    testString: 'assert(result.length == 2, "Your regex <code>myRegex</code> should match 2 items.");'
  - text: يجب أن يكون متغير <code>result</code> مصفوفة تحتوي على مجموعتين من <code>&quot;ss&quot;</code>
    testString: 'assert(result[0] == "ss" && result[1] == "ss", "The <code>result</code> variable should be an array with two matches of <code>"ss"</code>");'

Challenge Seed

let difficultSpelling = "Mississippi";
let myRegex = /change/; // Change this line
let result = difficultSpelling.match(myRegex);

Solution

// solution required