2.2 KiB
2.2 KiB
id | title | challengeType | videoUrl | localeTitle |
---|---|---|---|---|
587d7db4367417b2b2512b92 | Extract Matches | 1 | استخراج مباريات |
Description
.match()
. لاستخدام طريقة .match()
، قم بتطبيق الطريقة على سلسلة وتمريرها في regex داخل الأقواس. إليك مثال على ذلك: "مرحبا ، العالم!". المباراة (/ مرحبا /) ؛
// إرجاع ["مرحبًا"]
دع ourStr = "التعبيرات العادية"؛
اسمحوا ourRegex = / تعبيرات / ؛
ourStr.match (ourRegex)؛
// إرجاع ["التعبيرات"]
Instructions
.match()
طريقة .match()
لاستخراج كلمة coding
. Tests
tests:
- text: و <code>result</code> يجب أن يكون كلمة <code>coding</code>
testString: 'assert(result.join() === "coding", "The <code>result</code> should have the word <code>coding</code>");'
- text: يجب أن يبحث <code>codingRegex</code> regex <code>codingRegex</code> عن <code>coding</code>
testString: 'assert(codingRegex.source === "coding", "Your regex <code>codingRegex</code> should search for <code>coding</code>");'
- text: يجب عليك استخدام طريقة <code>.match()</code> .
testString: 'assert(code.match(/\.match\(.*\)/), "You should use the <code>.match()</code> method.");'
Challenge Seed
let extractStr = "Extract the word 'coding' from this string.";
let codingRegex = /change/; // Change this line
let result = extractStr; // Change this line
Solution
// solution required