Skip to content

Commit

Permalink
Merge pull request ziishaned#178 from niexia/patch-1
Browse files Browse the repository at this point in the history
update Chinese translation at section Lookaround
  • Loading branch information
ziishaned authored Dec 23, 2021
2 parents ed023fe + ac30dce commit 27c2e30
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions translations/README-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -358,11 +358,9 @@

## 4. 零宽度断言(前后预查)

先行断言和后发断言都属于**非捕获簇**(不捕获文本 ,也不针对组合计进行计数)。
先行断言用于判断所匹配的格式是否在另一个确定的格式之前,匹配结果不包含该确定格式(仅作为约束)。
先行断言和后发断言(合称 lookaround)都属于**非捕获组**(用于匹配模式,但不包括在匹配列表中)。当我们需要一个模式的前面或后面有另一个特定的模式时,就可以使用它们。

例如,我们想要获得所有跟在 `$` 符号后的数字,我们可以使用正后发断言 `(?<=\$)[0-9\.]*`
这个表达式匹配 `$` 开头,之后跟着 `0,1,2,3,4,5,6,7,8,9,.` 这些字符可以出现大于等于 0 次。
例如,我们希望从下面的输入字符串 `$4.44``$10.88` 中获得所有以 `$` 字符开头的数字,我们将使用以下的正则表达式 `(?<=\$)[0-9\.]*`。意思是:获取所有包含 `.` 并且前面是 `$` 的数字。

零宽度断言如下:

Expand Down

0 comments on commit 27c2e30

Please sign in to comment.