.match()
. لاستخدام طريقة .match()
، قم بتطبيق الطريقة على سلسلة وتمريرها في regex داخل الأقواس. إليك مثال على ذلك: "مرحبا ، العالم!". المباراة (/ مرحبا /) ؛
// إرجاع ["مرحبًا"]
دع ourStr = "التعبيرات العادية"؛
اسمحوا ourRegex = / تعبيرات / ؛
ourStr.match (ourRegex)؛
// إرجاع ["التعبيرات"]
.match()
طريقة .match()
لاستخراج كلمة coding
. result
يجب أن يكون كلمة coding
testString: 'assert(result.join() === "coding", "The result
should have the word coding
");'
- text: يجب أن يبحث codingRegex
regex codingRegex
عن coding
testString: 'assert(codingRegex.source === "coding", "Your regex codingRegex
should search for coding
");'
- text: يجب عليك استخدام طريقة .match()
.
testString: 'assert(code.match(/\.match\(.*\)/), "You should use the .match()
method.");'
```