60 lines
3.0 KiB
Markdown
60 lines
3.0 KiB
Markdown
---
|
|
id: 587d7db8367417b2b2512ba3
|
|
title: Match Whitespace
|
|
challengeType: 1
|
|
videoUrl: ''
|
|
localeTitle: تطابق الفراغ
|
|
---
|
|
|
|
## Description
|
|
<section id="description"> غطت التحديات حتى الآن الحروف المطابقة للأبجدية والأرقام. يمكنك أيضًا مطابقة المسافة البيضاء أو المسافات بين الأحرف. يمكنك البحث عن المسافات باستخدام <code>\s</code> ، وهي صغيرة <code>s</code> . لا يطابق هذا النمط المسافة البيضاء فحسب ، بل يطابق أيضًا أحرف الإرجاع ، وعلامة التبويب ، وتغذية النموذج ، وأحرف الخطوط الجديدة. يمكنك اعتباره مشابهًا لفئة الأحرف <code>[ \r\t\f\n\v]</code> . <blockquote style=";text-align:right;direction:rtl"> let whiteSpace = "Whitespace. Whitespace everywhere!" <br> اترك spaceRegex = / \ s / g؛ <br> whiteSpace.match (spaceRegex)؛ <br> // عائدات [" "، " "] <br></blockquote></section>
|
|
|
|
## Instructions
|
|
<section id="instructions"> غيّر <code>countWhiteSpace</code> regex للبحث عن أحرف بيضاء متعددة في سلسلة. </section>
|
|
|
|
## Tests
|
|
<section id='tests'>
|
|
|
|
```yml
|
|
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>"Men are from Mars and women are from Venus."</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>"Space: the final frontier."</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>"MindYourPersonalSpace"</code> أي مسافات في <code>"MindYourPersonalSpace"</code>
|
|
testString: 'assert("MindYourPersonalSpace".match(countWhiteSpace) == null, "Your regex should find no spaces in <code>"MindYourPersonalSpace"</code>");'
|
|
|
|
```
|
|
|
|
</section>
|
|
|
|
## Challenge Seed
|
|
<section id='challengeSeed'>
|
|
|
|
<div id='js-seed'>
|
|
|
|
```js
|
|
let sample = "Whitespace is important in separating words";
|
|
let countWhiteSpace = /change/; // Change this line
|
|
let result = sample.match(countWhiteSpace);
|
|
|
|
```
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</section>
|
|
|
|
## Solution
|
|
<section id='solution'>
|
|
|
|
```js
|
|
// solution required
|
|
```
|
|
</section>
|