fix: converted single to triple backticks4 (#36231)
This commit is contained in:
@@ -18,7 +18,8 @@ localeTitle: استخراج مباريات
|
||||
|
||||
## حل:
|
||||
|
||||
`let extractStr = "Extract the word 'coding' from this string.";
|
||||
let codingRegex = /coding/;
|
||||
let result = extractStr.match(codingRegex);
|
||||
`
|
||||
```javascript
|
||||
let extractStr = "Extract the word 'coding' from this string.";
|
||||
let codingRegex = /coding/;
|
||||
let result = extractStr.match(codingRegex);
|
||||
```
|
||||
@@ -10,7 +10,8 @@ localeTitle: العثور على شخصيات مع مطابقة كسول
|
||||
|
||||
#### حل:
|
||||
|
||||
`let text = "<h1>Winter is coming</h1>";
|
||||
let myRegex = /<h1>?/; // it's the answer!
|
||||
let result = text.match(myRegex);
|
||||
`
|
||||
```js
|
||||
let text = "<h1>Winter is coming</h1>";
|
||||
let myRegex = /<h1>?/; // it's the answer!
|
||||
let result = text.match(myRegex);
|
||||
```
|
||||
@@ -18,7 +18,8 @@ localeTitle: العثور على أكثر من المباراة الأولى
|
||||
|
||||
## حل
|
||||
|
||||
`let twinkleStar = "Twinkle, twinkle, little star";
|
||||
let starRegex = /twinkle/gi;
|
||||
let result = twinkleStar.match(starRegex);
|
||||
`
|
||||
```javascript
|
||||
let twinkleStar = "Twinkle, twinkle, little star";
|
||||
let starRegex = /twinkle/gi;
|
||||
let result = twinkleStar.match(starRegex);
|
||||
```
|
||||
@@ -21,17 +21,19 @@ localeTitle: العثور على واحد أو أكثر من المجرمين ف
|
||||
|
||||
هل تستخدم علامة "+" في تعبيرك العادي؟
|
||||
|
||||
`let regexp = /E+/; // returns E, EE, EEE patterns
|
||||
`
|
||||
```javascript
|
||||
let regexp = /E+/; // returns E, EE, EEE patterns
|
||||
```
|
||||
|
||||
### تحذير المفسد - الحل إلى الأمام
|
||||
|
||||
## حل
|
||||
|
||||
`let crowd = 'P1P2P3P4P5P6CCCP7P8P9';
|
||||
|
||||
let reCriminals = /C+/; // Change this line
|
||||
|
||||
let matchedCriminals = crowd.match(reCriminals);
|
||||
console.log(matchedCriminals);
|
||||
`
|
||||
```javascript
|
||||
let crowd = 'P1P2P3P4P5P6CCCP7P8P9';
|
||||
|
||||
let reCriminals = /C+/; // Change this line
|
||||
|
||||
let matchedCriminals = crowd.match(reCriminals);
|
||||
console.log(matchedCriminals);
|
||||
```
|
||||
@@ -14,7 +14,8 @@ localeTitle: تجاهل حالة أثناء المطابقة
|
||||
|
||||
## حل
|
||||
|
||||
`let myString = "freeCodeCamp";
|
||||
let fccRegex = /freeCodeCamp/i;
|
||||
let result = fccRegex.test(myString);
|
||||
`
|
||||
```javascript
|
||||
let myString = "freeCodeCamp";
|
||||
let fccRegex = /freeCodeCamp/i;
|
||||
let result = fccRegex.test(myString);
|
||||
```
|
||||
@@ -14,7 +14,8 @@ localeTitle: تطابق سلسلة حرفية مع الاحتمالات المخ
|
||||
|
||||
## حل:
|
||||
|
||||
`let petString = "James has a pet cat.";
|
||||
let petRegex = /dog|cat|bird|fish/;
|
||||
let result = petRegex.test(petString);
|
||||
`
|
||||
```javascriot
|
||||
let petString = "James has a pet cat.";
|
||||
let petRegex = /dog|cat|bird|fish/;
|
||||
let result = petRegex.test(petString);
|
||||
```
|
||||
@@ -16,8 +16,9 @@ localeTitle: المباراة جميع غير الارقام
|
||||
|
||||
## حل
|
||||
|
||||
`let noNumRegex = /\D/g;
|
||||
`
|
||||
```javascript
|
||||
let noNumRegex = /\D/g;
|
||||
```
|
||||
|
||||
## تفسير
|
||||
|
||||
|
||||
@@ -16,8 +16,9 @@ localeTitle: تطابق جميع الأرقام
|
||||
|
||||
## حل
|
||||
|
||||
`let numRegex = /\d/g;
|
||||
`
|
||||
```javascript
|
||||
let numRegex = /\d/g;
|
||||
```
|
||||
|
||||
## تفسير
|
||||
|
||||
|
||||
@@ -14,10 +14,11 @@ localeTitle: تطابق أي شيء مع فترة أحرف البدل
|
||||
|
||||
## حل
|
||||
|
||||
`let exampleStr = "Let's have fun with regular expressions!";
|
||||
let unRegex = /.un/; // Change this line
|
||||
let result = unRegex.test(exampleStr);
|
||||
`
|
||||
```javascript
|
||||
let exampleStr = "Let's have fun with regular expressions!";
|
||||
let unRegex = /.un/; // Change this line
|
||||
let result = unRegex.test(exampleStr);
|
||||
```
|
||||
|
||||
## كسبلايناتيون
|
||||
|
||||
|
||||
@@ -12,9 +12,10 @@ localeTitle: مباراة بداية أنماط سلسلة
|
||||
|
||||
جرِّب محيطك المعتاد بالأشرطة المائلة
|
||||
|
||||
`let testExp = /^test/;
|
||||
// returns true or false depending on whether test is found in the beginning of the string
|
||||
`
|
||||
```javascript
|
||||
let testExp = /^test/;
|
||||
// returns true or false depending on whether test is found in the beginning of the string
|
||||
```
|
||||
|
||||
### تلميح 2:
|
||||
|
||||
@@ -24,7 +25,8 @@ localeTitle: مباراة بداية أنماط سلسلة
|
||||
|
||||
## حل
|
||||
|
||||
`let rickyAndCal = "Cal and Ricky both like racing.";
|
||||
let calRegex = /^Cal/; // Change this line
|
||||
let result = calRegex.test(rickyAndCal);
|
||||
`
|
||||
```javascript
|
||||
let rickyAndCal = "Cal and Ricky both like racing.";
|
||||
let calRegex = /^Cal/; // Change this line
|
||||
let result = calRegex.test(rickyAndCal);
|
||||
```
|
||||
@@ -6,22 +6,24 @@ localeTitle: مطابقة الأحرف التي تحدث Zero أو أوقات إ
|
||||
|
||||
لا يجب أن يحدث أي حرف في تعبير regex يتبعه `*` في السلسلة التي تم اختبارها ، في حين يجب أن يظهر أي حرف في تعبير regex متبوعًا بـ `+` في سلسلة واحدة على الأقل ، كما هو موضح أدناه ،
|
||||
|
||||
`let phrase = "ba humbug";
|
||||
|
||||
let regexPlus = /bah+/;
|
||||
let regexStar = /bah*/;
|
||||
|
||||
regexPlus.test(phrase); // returns false
|
||||
regexStar.test(phrase); // returns true
|
||||
`
|
||||
```javascript
|
||||
let phrase = "ba humbug";
|
||||
|
||||
let regexPlus = /bah+/;
|
||||
let regexStar = /bah*/;
|
||||
|
||||
regexPlus.test(phrase); // returns false
|
||||
regexStar.test(phrase); // returns true
|
||||
```
|
||||
|
||||
كلاهما يسمحان بأي عدد من الأحداث من نفس الحرف في صف ، على سبيل المثال ،
|
||||
|
||||
`let phrase = "wooooow look at that!";
|
||||
|
||||
let regexPlus = /wo+w/;
|
||||
let regexStar = /wo*w/;
|
||||
|
||||
regexPlus.test(phrase); // returns true
|
||||
regexStar.test(phrase); // returns true
|
||||
`
|
||||
```javascript
|
||||
let phrase = "wooooow look at that!";
|
||||
|
||||
let regexPlus = /wo+w/;
|
||||
let regexStar = /wo*w/;
|
||||
|
||||
regexPlus.test(phrase); // returns true
|
||||
regexStar.test(phrase); // returns true
|
||||
```
|
||||
@@ -16,7 +16,8 @@ localeTitle: المباراة الحرفيه الاوتار
|
||||
|
||||
## حل:
|
||||
|
||||
`let waldoIsHiding = "Somewhere Waldo is hiding in this text.";
|
||||
let waldoRegex = /Waldo/; // Change this line
|
||||
let result = waldoRegex.test(waldoIsHiding);
|
||||
`
|
||||
```javascript
|
||||
let waldoIsHiding = "Somewhere Waldo is hiding in this text.";
|
||||
let waldoRegex = /Waldo/; // Change this line
|
||||
let result = waldoRegex.test(waldoIsHiding);
|
||||
```
|
||||
@@ -21,16 +21,18 @@ localeTitle: أرقام المباراة ورسائل الأبجدية
|
||||
|
||||
هل تذكر تمكين إشارات regexp مثل "i" لتجاهل الحالة و "g" لإرجاع قيم متعددة؟ إذا كان الأمر كذلك ، فهل تقوم بتضمين كل من مطابقة الأحرف للأرقام والحروف؟
|
||||
|
||||
`let regexp = /[a-z1-100]/ig
|
||||
// above code returns all characters from A to Z, along with all numbers from 1 to 100
|
||||
// this includes the letter A and Z and the numbers 1 and 100
|
||||
`
|
||||
```javascript
|
||||
let regexp = /[a-z1-100]/ig
|
||||
// above code returns all characters from A to Z, along with all numbers from 1 to 100
|
||||
// this includes the letter A and Z and the numbers 1 and 100
|
||||
```
|
||||
|
||||
### تنبيه المفسد - الحل إلى الأمام
|
||||
|
||||
## حل
|
||||
|
||||
`let quoteSample = "Blueberry 3.141592653s are delicious.";
|
||||
let myRegex = /[h-s2-6]/ig; // Change this line
|
||||
let result = quoteSample.match(myRegex); // Change this line
|
||||
`
|
||||
```javascript
|
||||
let quoteSample = "Blueberry 3.141592653s are delicious.";
|
||||
let myRegex = /[h-s2-6]/ig; // Change this line
|
||||
let result = quoteSample.match(myRegex); // Change this line
|
||||
```
|
||||
@@ -20,7 +20,8 @@ localeTitle: تطابق شخصية واحدة مع إمكانيات متعددة
|
||||
|
||||
## حل
|
||||
|
||||
`let quoteSample = "Beware of bugs in the above code; I have only proved it correct, not tried it.";
|
||||
let vowelRegex = /[aeiou]/ig; // Change this line
|
||||
let result = quoteSample.match(vowelRegex); // Change this line
|
||||
`
|
||||
```javascript
|
||||
let quoteSample = "Beware of bugs in the above code; I have only proved it correct, not tried it.";
|
||||
let vowelRegex = /[aeiou]/ig; // Change this line
|
||||
let result = quoteSample.match(vowelRegex); // Change this line
|
||||
```
|
||||
@@ -23,14 +23,16 @@ localeTitle: مطابقة أحرف مفردة غير محددة
|
||||
|
||||
تأكد من التحقق مما إذا كان نطاق الأرقام صحيحًا - يطالبنا التحدي بإنهاء جميع الأرقام من 0 إلى 99. يمكن القيام بذلك باستخدام علامة الإبطال السلبي الموضوعة مباشرة بعد أول شريحة افتتاحية من كلمة regexp الخاصة بك.
|
||||
|
||||
`let numbersRegExp = /[^0-99]/ig;
|
||||
`
|
||||
```javacsript
|
||||
let numbersRegExp = /[^0-99]/ig;
|
||||
```
|
||||
|
||||
### تنبيه المفسد - الحل إلى الأمام
|
||||
|
||||
## حل
|
||||
|
||||
`let quoteSample = "3 blind mice.";
|
||||
let myRegex = /[^aeiou^0-99]/ig; // Change this line
|
||||
let result = quoteSample.match(myRegex); // Change this line
|
||||
`
|
||||
```javascript
|
||||
let quoteSample = "3 blind mice.";
|
||||
let myRegex = /[^aeiou^0-99]/ig; // Change this line
|
||||
let result = quoteSample.match(myRegex); // Change this line
|
||||
```
|
||||
@@ -11,7 +11,8 @@ localeTitle: الإيجابية و السلبية Lookahead
|
||||
|
||||
## حل :
|
||||
|
||||
`let sampleWord = "astronaut";
|
||||
let pwRegex = /(?=\w{5,})(?=\D*\d{2})/;
|
||||
let result = pwRegex.test(sampleWord);
|
||||
`
|
||||
```javascript
|
||||
let sampleWord = "astronaut";
|
||||
let pwRegex = /(?=\w{5,})(?=\D*\d{2})/;
|
||||
let result = pwRegex.test(sampleWord);
|
||||
```
|
||||
@@ -18,7 +18,8 @@ localeTitle: إزالة Whitespace من البداية والنهاية
|
||||
|
||||
## حل:
|
||||
|
||||
`let hello = " Hello, World! ";
|
||||
let wsRegex = /^\s+|\s+$/g; // Change this line
|
||||
let result = hello.replace(wsRegex, ''); // Change this line
|
||||
`
|
||||
```javascript
|
||||
let hello = " Hello, World! ";
|
||||
let wsRegex = /^\s+|\s+$/g; // Change this line
|
||||
let result = hello.replace(wsRegex, ''); // Change this line
|
||||
```
|
||||
@@ -15,13 +15,15 @@ localeTitle: تقييد أسماء المستخدمين المحتملين
|
||||
|
||||
1. الأرقام الوحيدة في اسم المستخدم يجب أن تكون في النهاية. `\d$` يمكن أن يكون هناك صفر أو أكثر منهم في النهاية. `*`
|
||||
|
||||
`/\d*$/;
|
||||
`
|
||||
```javascript
|
||||
/\d*$/;
|
||||
```
|
||||
|
||||
2. يمكن أن تكون أحرف اسم المستخدم صغيرة وأحرف كبيرة. `i`
|
||||
|
||||
`/\d*$/i;
|
||||
`
|
||||
```javascript
|
||||
/\d*$/i;
|
||||
```
|
||||
|
||||
3. يجب أن تتكون أسماء المستخدمين من حرفين على الأقل. `{2,}` يمكن لاسم المستخدم المكون من حرفين فقط استخدام أحرف الحروف الأبجدية. `^[az]`
|
||||
|
||||
|
||||
@@ -8,10 +8,11 @@ localeTitle: إعادة استخدام الأنماط باستخدام مجمو
|
||||
|
||||
كود المقدمة أدناه:
|
||||
|
||||
`let testString = "test test test ";
|
||||
let reRegex =/(test)\s\1/;
|
||||
let result = reRegex.test(testString);
|
||||
`
|
||||
```javascript
|
||||
let testString = "test test test ";
|
||||
let reRegex =/(test)\s\1/;
|
||||
let result = reRegex.test(testString);
|
||||
```
|
||||
|
||||
سوف تتطابق `result` مع `test test` فقط لأن `\1` في هذا المثال تشير إلى نفس النص الذي تم مؤخرًا تطابقه مع المجموعة الأولى `(test)` .
|
||||
|
||||
@@ -27,10 +28,11 @@ localeTitle: إعادة استخدام الأنماط باستخدام مجمو
|
||||
|
||||
نظرا للرمز أدناه:
|
||||
|
||||
`let testString = "test test test ";
|
||||
let reRegex =/(test)(\s)\1\2\1/;
|
||||
let result = reRegex.test(testString);
|
||||
`
|
||||
```javascript
|
||||
let testString = "test test test ";
|
||||
let reRegex =/(test)(\s)\1\2\1/;
|
||||
let result = reRegex.test(testString);
|
||||
```
|
||||
|
||||
سيطابق `test test test` كامل `test test test` بسبب: `\1` يكرر (اختبار) `\2` يكرر (\\ s)
|
||||
|
||||
@@ -38,10 +40,11 @@ localeTitle: إعادة استخدام الأنماط باستخدام مجمو
|
||||
|
||||
الكود أدناه:
|
||||
|
||||
`let testString = "test test test test test test";
|
||||
let reRegex =/(test)(\s)\1\2\1/g;
|
||||
let result = reRegex.test(testString);
|
||||
`
|
||||
```javascript
|
||||
let testString = "test test test test test test";
|
||||
let reRegex =/(test)(\s)\1\2\1/g;
|
||||
let result = reRegex.test(testString);
|
||||
```
|
||||
|
||||
نظرًا لأننا استخدمنا `\g` ، فلن يعود التعبير المعتاد الخاص بنا بعد أول مباراة كاملة ( `test test test` ) ويطابق كل التكرار.
|
||||
|
||||
@@ -49,7 +52,8 @@ localeTitle: إعادة استخدام الأنماط باستخدام مجمو
|
||||
|
||||
## حل:
|
||||
|
||||
`let repeatNum = "42 42 42";
|
||||
let reRegex = /^(\d+)\s\1\s\1$/;
|
||||
let result = reRegex.test(repeatNum);
|
||||
`
|
||||
```javascript
|
||||
let repeatNum = "42 42 42";
|
||||
let reRegex = /^(\d+)\s\1\s\1$/;
|
||||
let result = reRegex.test(repeatNum);
|
||||
```
|
||||
|
||||
@@ -8,15 +8,16 @@ localeTitle: تحديد العلوي والسفلي عدد من المباريا
|
||||
|
||||
كل هذه السلاسل ستعود `true` :
|
||||
|
||||
`let threeAs = "aaa";
|
||||
let fourAs = "aaaa";
|
||||
let sevenAs = "aaaaaaa";
|
||||
|
||||
let myRegex = /a{2,4}/;
|
||||
myRegex.test(threeAs) ; // true
|
||||
myRegex.test(fourAs) ; // true
|
||||
myRegex.test(sevenAs) ; // true
|
||||
`
|
||||
```javascript
|
||||
let threeAs = "aaa";
|
||||
let fourAs = "aaaa";
|
||||
let sevenAs = "aaaaaaa";
|
||||
|
||||
let myRegex = /a{2,4}/;
|
||||
myRegex.test(threeAs) ; // true
|
||||
myRegex.test(fourAs) ; // true
|
||||
myRegex.test(sevenAs) ; // true
|
||||
```
|
||||
|
||||
## Spolier Alert!
|
||||
|
||||
@@ -24,7 +25,8 @@ localeTitle: تحديد العلوي والسفلي عدد من المباريا
|
||||
|
||||
## حل:
|
||||
|
||||
`let ohStr = "Ohhh no";
|
||||
let ohRegex = /Oh{3,6}\sno/; // Change this line
|
||||
let result = ohRegex.test(ohStr);
|
||||
`
|
||||
```javascript
|
||||
let ohStr = "Ohhh no";
|
||||
let ohRegex = /Oh{3,6}\sno/; // Change this line
|
||||
let result = ohRegex.test(ohStr);
|
||||
```
|
||||
@@ -14,8 +14,9 @@ localeTitle: استخدم مجموعات الالتقاط للبحث واستب
|
||||
|
||||
## حل
|
||||
|
||||
`let huhText = "This sandwich is good.";
|
||||
let fixRegex = /good/; // Change this line
|
||||
let replaceText = "okey-dokey"; // Change this line
|
||||
let result = huhText.replace(fixRegex, replaceText);
|
||||
`
|
||||
```javascript
|
||||
let huhText = "This sandwich is good.";
|
||||
let fixRegex = /good/; // Change this line
|
||||
let replaceText = "okey-dokey"; // Change this line
|
||||
let result = huhText.replace(fixRegex, replaceText);
|
||||
```
|
||||
@@ -14,7 +14,8 @@ localeTitle: باستخدام طريقة الاختبار
|
||||
|
||||
## حل
|
||||
|
||||
`let myString = "Hello, World!";
|
||||
let myRegex = /Hello/;
|
||||
let result = myRegex.test(myString); // Change this line
|
||||
`
|
||||
```javascript
|
||||
let myString = "Hello, World!";
|
||||
let myRegex = /Hello/;
|
||||
let result = myRegex.test(myString); // Change this line
|
||||
```
|
||||
Reference in New Issue
Block a user