fix: update guide hint to properly declare regex (#34625)
This commit is contained in:
@ -17,8 +17,8 @@ localeTitle: إعادة استخدام الأنماط باستخدام مجمو
|
|||||||
|
|
||||||
إذا كنا سنترجم التعبير المعتاد حرفياً ، فسيبدو شيئًا كالتالي:
|
إذا كنا سنترجم التعبير المعتاد حرفياً ، فسيبدو شيئًا كالتالي:
|
||||||
|
|
||||||
`let re = /(test)\s\1;
|
`let re = /(test)\s\1/;
|
||||||
let literalRe = /test\stest;
|
let literalRe = /test\stest/;
|
||||||
`
|
`
|
||||||
|
|
||||||
كل من `rea` و `literalRe` تطابق نفس الشيء.
|
كل من `rea` و `literalRe` تطابق نفس الشيء.
|
||||||
@ -52,4 +52,4 @@ localeTitle: إعادة استخدام الأنماط باستخدام مجمو
|
|||||||
`let repeatNum = "42 42 42";
|
`let repeatNum = "42 42 42";
|
||||||
let reRegex = /^(\d+)\s\1\s\1$/;
|
let reRegex = /^(\d+)\s\1\s\1$/;
|
||||||
let result = reRegex.test(repeatNum);
|
let result = reRegex.test(repeatNum);
|
||||||
`
|
`
|
||||||
|
@ -19,8 +19,8 @@ let testString = "test test test ";
|
|||||||
如果我们要正面翻译正则表达式,它看起来像这样:
|
如果我们要正面翻译正则表达式,它看起来像这样:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
let re = /(test)\s\1;
|
let re = /(test)\s\1/;
|
||||||
let literalRe = /test\stest;
|
let literalRe = /test\stest/;
|
||||||
```
|
```
|
||||||
|
|
||||||
`rea`和`literalRe`都会匹配相同的东西。
|
`rea`和`literalRe`都会匹配相同的东西。
|
||||||
@ -58,4 +58,4 @@ let repeatNum = "42 42 42";
|
|||||||
let reRegex = /^(\d+)\s\1\s\1$/;
|
let reRegex = /^(\d+)\s\1\s\1$/;
|
||||||
let result = reRegex.test(repeatNum);
|
let result = reRegex.test(repeatNum);
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -12,11 +12,11 @@ let result = reRegex.test(testString);
|
|||||||
```
|
```
|
||||||
`result` will match only `test test` because `\1` in this example stands for the same text as most recently matched by the 1st capturing group `(test)`.
|
`result` will match only `test test` because `\1` in this example stands for the same text as most recently matched by the 1st capturing group `(test)`.
|
||||||
|
|
||||||
If we were to lierally translate the regex, it would look something like this:
|
If we were to literally translate the regex, it would look something like this:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
let re = /(test)\s\1;
|
let re = /(test)\s\1/;
|
||||||
let literalRe = /test\stest;
|
let literalRe = /test\stest/;
|
||||||
```
|
```
|
||||||
Both `rea` and `literalRe` would match the same thing.
|
Both `rea` and `literalRe` would match the same thing.
|
||||||
|
|
||||||
|
@ -19,8 +19,8 @@ let testString = "test test test ";
|
|||||||
Se fôssemos traduzir literalmente o regex, seria algo como isto:
|
Se fôssemos traduzir literalmente o regex, seria algo como isto:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
let re = /(test)\s\1;
|
let re = /(test)\s\1/;
|
||||||
let literalRe = /test\stest;
|
let literalRe = /test\stest/;
|
||||||
```
|
```
|
||||||
|
|
||||||
Ambos `rea` e `literalRe` combinariam com a mesma coisa.
|
Ambos `rea` e `literalRe` combinariam com a mesma coisa.
|
||||||
@ -58,4 +58,4 @@ let repeatNum = "42 42 42";
|
|||||||
let reRegex = /^(\d+)\s\1\s\1$/;
|
let reRegex = /^(\d+)\s\1\s\1$/;
|
||||||
let result = reRegex.test(repeatNum);
|
let result = reRegex.test(repeatNum);
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -19,8 +19,8 @@ let testString = "test test test ";
|
|||||||
Если бы мы должны были перевести регулярное выражение, это выглядело бы примерно так:
|
Если бы мы должны были перевести регулярное выражение, это выглядело бы примерно так:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
let re = /(test)\s\1;
|
let re = /(test)\s\1/;
|
||||||
let literalRe = /test\stest;
|
let literalRe = /test\stest/;
|
||||||
```
|
```
|
||||||
|
|
||||||
И `rea` и `literalRe` будут соответствовать одному и тому же.
|
И `rea` и `literalRe` будут соответствовать одному и тому же.
|
||||||
@ -58,4 +58,4 @@ let repeatNum = "42 42 42";
|
|||||||
let reRegex = /^(\d+)\s\1\s\1$/;
|
let reRegex = /^(\d+)\s\1\s\1$/;
|
||||||
let result = reRegex.test(repeatNum);
|
let result = reRegex.test(repeatNum);
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -19,8 +19,8 @@ let testString = "test test test ";
|
|||||||
Si tuviéramos que traducir literalmente la expresión regular, se vería algo así:
|
Si tuviéramos que traducir literalmente la expresión regular, se vería algo así:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
let re = /(test)\s\1;
|
let re = /(test)\s\1/;
|
||||||
let literalRe = /test\stest;
|
let literalRe = /test\stest/;
|
||||||
```
|
```
|
||||||
|
|
||||||
Tanto `rea` como `literalRe` coincidirían con la misma cosa.
|
Tanto `rea` como `literalRe` coincidirían con la misma cosa.
|
||||||
@ -58,4 +58,4 @@ let repeatNum = "42 42 42";
|
|||||||
let reRegex = /^(\d+)\s\1\s\1$/;
|
let reRegex = /^(\d+)\s\1\s\1$/;
|
||||||
let result = reRegex.test(repeatNum);
|
let result = reRegex.test(repeatNum);
|
||||||
|
|
||||||
```
|
```
|
||||||
|
Reference in New Issue
Block a user