From 755ae62bff06891ad2f0764f45e9cb852926ad96 Mon Sep 17 00:00:00 2001 From: EdgarAllanzp Date: Tue, 30 Jan 2018 12:30:10 +0800 Subject: [PATCH 1/2] fix example error at section Greedy vs lazy matching. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f89d1cc..d49c725 100644 --- a/README.md +++ b/README.md @@ -546,7 +546,7 @@ By default regex will do greedy matching , means it will match as long as possible. we can use `?` to match in lazy way means as short as possible
-"/(.*at)/" => The fat cat sat on the mat. 
+"/(.*at)/" => The fat cat sat on the mat. [Test the regular expression](https://regex101.com/r/AyAdgJ/1) From 30d0fa33ef4bc14abeda92c0230092e569bf069d Mon Sep 17 00:00:00 2001 From: EdgarAllanzp Date: Tue, 30 Jan 2018 18:02:12 +0800 Subject: [PATCH 2/2] Chinese translation at section 'Greedy vs lazy matching'. --- README-cn.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README-cn.md b/README-cn.md index 5899a10..f31fdf7 100644 --- a/README-cn.md +++ b/README-cn.md @@ -472,6 +472,21 @@ [在线练习](https://regex101.com/r/E88WE2/1) +### 6. 贪婪匹配与惰性匹配 (Greedy vs lazy matching) + +正则表达式默认采用贪婪匹配模式,在该模式下意味着会匹配尽可能长的子串。我们可以使用 `?` 将贪婪匹配模式转化为惰性匹配模式。 + +
+"/(.*at)/" => The fat cat sat on the mat. 
+ +[在线练习](https://regex101.com/r/AyAdgJ/1) + +
+"/(.*?at)/" => The fat cat sat on the mat. 
+ + +[在线练习](https://regex101.com/r/AyAdgJ/2) + ## 贡献 * 报告问题