5.5 KiB
5.5 KiB
id | title | challengeType | videoUrl | localeTitle |
---|---|---|---|---|
587d7db5367417b2b2512b94 | Match Anything with Wildcard Period | 1 | تطابق أي شيء مع فترة أحرف البدل |
Description
.
حرف البدل .
سوف تطابق أي حرف واحد. ويطلق على حرف البدل أيضا dot
period
. يمكنك استخدام حرف البدل تمامًا مثل أي حرف آخر في regex. على سبيل المثال ، إذا أردت مطابقة "hug"
و "huh"
و "hut"
و "hum"
، فيمكنك استخدام regex /hu./
لمطابقة كل الكلمات الأربع. لندع humStr = "سوف ألعب أغنية" ؛
let hugStr = "Bear hug"؛
let huRegex = /hu./؛
humStr.match (huRegex)؛ // Returns ["hum"]
hugStr.match (huRegex)؛ // Returns ["hug"]
Instructions
unRegex
بحيث يتطابق مع السلاسل "run"
و "sun"
و "fun"
و "pun"
و "nun"
و "bun"
. يجب أن يستخدم تعبيرك العادي حرف حرف البدل. Tests
tests:
- text: يجب عليك استخدام طريقة <code>.test()</code> .
testString: 'assert(code.match(/\.test\(.*\)/), "You should use the <code>.test()</code> method.");'
- text: يجب عليك استخدام حرف البدل في regex <code>unRegex</code>
testString: 'assert(/\./.test(unRegex.source), "You should use the wildcard character in your regex <code>unRegex</code>");'
- text: يجب أن يطابق regex <code>unRegex</code> <code>"run"</code> في <code>"Let us go on a run."</code>
testString: 'assert(unRegex.test("Let us go on a run."), "Your regex <code>unRegex</code> should match <code>"run"</code> in <code>"Let us go on a run."</code>");'
- text: يجب أن يتطابق <code>unRegex</code> regex <code>unRegex</code> مع كلمة <code>"sun"</code> في <code>"The sun is out today."</code>
testString: 'assert(unRegex.test("The sun is out today."), "Your regex <code>unRegex</code> should match <code>"sun"</code> in <code>"The sun is out today."</code>");'
- text: يجب أن يطابق regex <code>unRegex</code> <code>"fun"</code> في <code>"Coding is a lot of fun."</code>
testString: 'assert(unRegex.test("Coding is a lot of fun."), "Your regex <code>unRegex</code> should match <code>"fun"</code> in <code>"Coding is a lot of fun."</code>");'
- text: يجب أن يتطابق <code>"pun"</code> regex <code>unRegex</code> مع <code>"pun"</code> في <code>"Seven days without a pun makes one weak."</code>
testString: 'assert(unRegex.test("Seven days without a pun makes one weak."), "Your regex <code>unRegex</code> should match <code>"pun"</code> in <code>"Seven days without a pun makes one weak."</code>");'
- text: يجب أن يتطابق <code>unRegex</code> regex <code>unRegex</code> مع <code>"nun"</code> في <code>"One takes a vow to be a nun."</code> <code>unRegex</code> <code>"One takes a vow to be a nun."</code>
testString: 'assert(unRegex.test("One takes a vow to be a nun."), "Your regex <code>unRegex</code> should match <code>"nun"</code> in <code>"One takes a vow to be a nun."</code>");'
- text: يجب أن تتطابق مع regex <code>unRegex</code> <code>"bun"</code> في <code>"She got fired from the hot dog stand for putting her hair in a bun."</code> <code>unRegex</code> <code>"She got fired from the hot dog stand for putting her hair in a bun."</code>
testString: 'assert(unRegex.test("She got fired from the hot dog stand for putting her hair in a bun."), "Your regex <code>unRegex</code> should match <code>"bun"</code> in <code>"She got fired from the hot dog stand for putting her hair in a bun."</code>");'
- text: يجب ألا يطابق regex <code>unRegex</code> <code>"There is a bug in my code."</code>
testString: 'assert(!unRegex.test("There is a bug in my code."), "Your regex <code>unRegex</code> should not match <code>"There is a bug in my code."</code>");'
- text: يجب ألا يتطابق التعبير <code>unRegex</code> regex <code>unRegex</code> مع <code>"Catch me if you can."</code>
testString: 'assert(!unRegex.test("Can me if you can."), "Your regex <code>unRegex</code> should not match <code>"Catch me if you can."</code>");'
Challenge Seed
let exampleStr = "Let's have fun with regular expressions!";
let unRegex = /change/; // Change this line
let result = unRegex.test(exampleStr);
Solution
// solution required