mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-02-24 20:01:39 -05:00
2.1 KiB
2.1 KiB
id, title, challengeType, forumTopicId, dashedName
| id | title | challengeType | forumTopicId | dashedName |
|---|---|---|---|---|
| 587d7db3367417b2b2512b8f | مطابقة النصوص الحرفية | 1 | 301355 | match-literal-strings |
--description--
في التحدي الأخير، بحثت عن كلمة Hello باستخدام regular expression الاتي /Hello/. هذا regex يبحث عن مطابقة حرفية في المقطع النصي الآتي Hello. إليك مثال آخر يبحث عن مطابقة حرفية في المقطع النصي الآتي Kevin:
let testStr = "Hello, my name is Kevin.";
let testRegex = /Kevin/;
testRegex.test(testStr);
هذا الاختبار test سيرجع true.
لن تتطابق أي أشكال أخرى من Kevin. على سبيل المثال، لن يتطابق الـ regex الاتي /Kevin/ مع kevin أو KEVIN.
let wrongRegex = /kevin/;
wrongRegex.test(testStr);
هذا الاختبار test سيرجع false.
والتحدي المستقبلي سيبين كيفية مطابقة تلك الأشكال الأخرى أيضا.
--instructions--
أكمل regex الأتي waldoRegex للعثور على "Waldo" في المقطع (string) النصية waldoIsHiding مع مطابقة حرفية.
--hints--
إن regex الخاص بك waldoRegex يجب أن يجد المقطع النصي الآتي Waldo
waldoRegex.lastIndex = 0;
assert(waldoRegex.test(waldoIsHiding));
يَجِبُ ألاّ يبحث regex الخاص بك waldoRegex عن أي شئ أخر.
waldoRegex.lastIndex = 0;
assert(!waldoRegex.test('Somewhere is hiding in this text.'));
يجب عليك إجراء مطابقة حرفية للمقطع النصية (string) باستخدام regex الخاص بك.
assert(!/\/.*\/i/.test(code));
--seed--
--seed-contents--
let waldoIsHiding = "Somewhere Waldo is hiding in this text.";
let waldoRegex = /search/; // Change this line
let result = waldoRegex.test(waldoIsHiding);
--solutions--
let waldoIsHiding = "Somewhere Waldo is hiding in this text.";
let waldoRegex = /Waldo/; // Change this line
let result = waldoRegex.test(waldoIsHiding);