freeCodeCamp/curriculum/challenges/arabic/02-javascript-algorithms-an.../regular-expressions/remove-whitespace-from-star...

1.9 KiB

id title challengeType videoUrl localeTitle
587d7dbb367417b2b2512bac Remove Whitespace from Start and End 1 إزالة Whitespace من البداية والنهاية

Description

في بعض الأحيان لا تكون الأحرف البيضاء حول السلاسل مطلوبة ولكن هناك. المعالجة النموذجية للسلاسل هي إزالة المسافة البيضاء في بداية ونهاية.

Instructions

اكتب regex واستخدم أساليب السلسلة المناسبة لإزالة المسافات البيضاء في بداية ونهاية السلاسل. ملحوظة
.trim() طريقة .trim() هنا ، ولكن ستحتاج إلى إكمال هذا التحدي باستخدام التعبيرات العادية.

Tests

tests:
  - text: 'يجب أن تساوي <code>result</code> <code>&quot;Hello, World!&quot;</code>'
    testString: 'assert(result == "Hello, World!", "<code>result</code> should equal to <code>"Hello, World!"</code>");'
  - text: يجب عدم استخدام طريقة <code>.trim()</code> .
    testString: 'assert(!code.match(/\.trim\(.*?\)/), "You should not use the <code>.trim()</code> method.");'
  - text: لا ينبغي تعيين متغير <code>result</code> مساو لسلسلة.
    testString: 'assert(!code.match(/result\s*=\s*".*?"/), "The <code>result</code> variable should not be set equal to a string.");'

Challenge Seed

let hello = "   Hello, World!  ";
let wsRegex = /change/; // Change this line
let result = hello; // Change this line

Solution

// solution required