Skip to content

Commit 304cb88

Browse files
mancuojsonghn233
andauthored
docs: update article.md (#1148)
* docs: update article.md * Update 9-regular-expressions/01-regexp-introduction/article.md Co-authored-by: Songhn <songhn233@gmail.com> --------- Co-authored-by: Songhn <songhn233@gmail.com>
1 parent 21c7195 commit 304cb88

File tree

1 file changed

+6
-6
lines changed
  • 9-regular-expressions/01-regexp-introduction

1 file changed

+6
-6
lines changed

9-regular-expressions/01-regexp-introduction/article.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
## 正则表达式
88

9-
正则表达式(可叫作 "regexp",或 "reg")包扩 **模式** 和可选的 **修饰符**
9+
正则表达式(可叫作 "regexp",或 "reg") **模式** 和可选的 **修饰符** 组成
1010

1111
有两种创建正则表达式对象的语法。
1212

@@ -23,13 +23,13 @@ regexp = /pattern/; // 没有修饰符
2323
regexp = /pattern/gmi; // 带有修饰符 g、m 和 i(后面会讲到)
2424
```
2525

26-
斜线 `pattern:/.../` 告诉 JavaScript 我们正在创建一个正则表达式。它的作用与字符串引号的作用相同
26+
斜线 `pattern:/.../` 告诉 JavaScript 我们正在创建一个正则表达式。它的作用与字符串的引号作用相同
2727

2828
在这两种情况下,`regexp` 都会成为内建类 `RegExp` 的一个实例。
2929

3030
这两种语法之间的主要区别在于,使用斜线 `/.../` 的模式不允许插入表达式(如带有 `${...}` 的字符串模板)。它是完全静态的。
3131

32-
在我们写代码时就知道正则表达式时则会使用斜线的方式 —— 这是最常见的情况。当我们需要从动态生成的字符串“动态”创建正则表达式时,更经常使用 `new RegExp`。例如:
32+
在我们写代码时就知道正则表达式时则会使用斜线的方式 —— 这是最常见的情况。而当我们需要从动态生成的字符串创建一个正则表达式时,更常使用 `new RegExp`。例如:
3333

3434
```js
3535
let tag = prompt("What tag do you want to find?", "h2");
@@ -39,9 +39,9 @@ let regexp = new RegExp(`<${tag}>`); // 如果在上方输入到 prompt 中的
3939

4040
## 修饰符
4141

42-
正则表达式可能会有的会影响搜索结果的修饰符
42+
正则表达式可能有影响搜索结果的修饰符
4343

44-
在 JavaScript 中, 6 个修饰符:
44+
在 JavaScript 中,只有 6 个修饰符:
4545

4646
`pattern:i`
4747
: 使用此修饰符后,搜索时不区分大小写:`A``a` 之间没有区别(请参见下面的示例)。
@@ -59,7 +59,7 @@ let regexp = new RegExp(`<${tag}>`); // 如果在上方输入到 prompt 中的
5959
: 开启完整的 Unicode 支持。该修饰符能够正确处理代理对。详见 <info:regexp-unicode>
6060

6161
`pattern:y`
62-
: 粘滞模式,在文本中的确切位置搜索(详见 <info:regexp-sticky>
62+
: 粘滞(Sticky)模式,在文本中的确切位置搜索(详见 <info:regexp-sticky>
6363

6464

6565
```smart header="颜色"

0 commit comments

Comments
 (0)