freeCodeCamp/curriculum/challenges/arabic/02-javascript-algorithms-an.../regular-expressions/match-whitespace.arabic.md

3.0 KiB

id title challengeType videoUrl localeTitle
587d7db8367417b2b2512ba3 Match Whitespace 1 تطابق الفراغ

Description

غطت التحديات حتى الآن الحروف المطابقة للأبجدية والأرقام. يمكنك أيضًا مطابقة المسافة البيضاء أو المسافات بين الأحرف. يمكنك البحث عن المسافات باستخدام \s ، وهي صغيرة s . لا يطابق هذا النمط المسافة البيضاء فحسب ، بل يطابق أيضًا أحرف الإرجاع ، وعلامة التبويب ، وتغذية النموذج ، وأحرف الخطوط الجديدة. يمكنك اعتباره مشابهًا لفئة الأحرف [ \r\t\f\n\v] .
let whiteSpace = "Whitespace. Whitespace everywhere!"
اترك spaceRegex = / \ s / g؛
whiteSpace.match (spaceRegex)؛
// عائدات [" "، " "]

Instructions

غيّر countWhiteSpace regex للبحث عن أحرف بيضاء متعددة في سلسلة.

Tests

tests:
  - text: يجب أن يستخدم تعبيرك العادي العلم العام.
    testString: 'assert(countWhiteSpace.global, "Your regex should use the global flag.");'
  - text: يجب أن يستخدم تعبيرك العادي الحرف المختصر
    testString: 'assert(/\\s/.test(countWhiteSpace.source), "Your regex should use the shorthand character <code>\s</code> to match all whitespace characters.");'
  - text: يجب أن يعثر تعبيرك المعتاد على ثماني مساحات في <code>&quot;Men are from Mars and women are from Venus.&quot;</code>
    testString: 'assert("Men are from Mars and women are from Venus.".match(countWhiteSpace).length == 8, "Your regex should find eight spaces in <code>"Men are from Mars and women are from Venus."</code>");'
  - text: 'يجب أن يعثر تعبيرك المعتاد على ثلاث مسافات في <code>&quot;Space: the final frontier.&quot;</code>'
    testString: 'assert("Space: the final frontier.".match(countWhiteSpace).length == 3, "Your regex should find three spaces in <code>"Space: the final frontier."</code>");'
  - text: يجب ألا يجد <code>&quot;MindYourPersonalSpace&quot;</code> أي مسافات في <code>&quot;MindYourPersonalSpace&quot;</code>
    testString: 'assert("MindYourPersonalSpace".match(countWhiteSpace) == null, "Your regex should find no spaces in <code>"MindYourPersonalSpace"</code>");'

Challenge Seed

let sample = "Whitespace is important in separating words";
let countWhiteSpace = /change/; // Change this line
let result = sample.match(countWhiteSpace);

Solution

// solution required