"Hello" باستخدام التعبير العادي /Hello/ . بحث هذا التعبير المنطقي عن تطابق حرفي لسلسلة "Hello" . إليك مثال آخر يبحث عن مطابقة حرفية لسلسلة "Kevin" : let testStr = "مرحبًا ، اسمي كيفن."؛أي أشكال أخرى من
let testRegex = / Kevin /؛
testRegex.test (testStr)؛
// يعود صحيح
"Kevin" لن تتطابق. على سبيل المثال ، لن يتطابق regex /Kevin/ مع "kevin" أو "KEVIN" . let wrongRegex = / kevin /؛سيظهر تحدٍّ مستقبلي كيفية مضاهاة هذه الأشكال الأخرى أيضًا.
wrongRegex.test (testStr)؛
// إرجاع خاطئة
waldoRegex regex للعثور على "Waldo" في السلسلة waldoIsHiding مع مطابقة حرفية. waldoRegex regex الخاص بك "Waldo"
testString: 'assert(waldoRegex.test(waldoIsHiding), "Your regex waldoRegex should find "Waldo"");'
- text: يجب ألا يبحث regex waldoRegex عن أي شيء آخر.
testString: 'assert(!waldoRegex.test("Somewhere is hiding in this text."), "Your regex waldoRegex should not search for anything else.");'
- text: يجب إجراء مطابقة سلسلة حرفية مع تعبيرك المعتاد.
testString: 'assert(!/\/.*\/i/.test(code), "You should perform a literal string match with your regex.");'
```