mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-11-13 09:16:10 +08:00
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
正则表达式语法和使用的详细信息请参考 [维基百科](http://en.wikipedia.org/wiki/Regular_expression)。
|
正则表达式语法和使用的详细信息请参考 [维基百科](http://en.wikipedia.org/wiki/Regular_expression)。
|
||||||
|
|
||||||
在下面的程序里,我们将在字符串中对正则表达式进行匹配。
|
在下面的程序里,我们将在字符串中对正则表达式模式(pattern)进行匹配。
|
||||||
|
|
||||||
如果是简单模式,使用 `Match` 方法便可:
|
如果是简单模式,使用 `Match` 方法便可:
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@ ok, _ := regexp.Match(pat, []byte(searchIn))
|
|||||||
ok, _ := regexp.MatchString(pat, searchIn)
|
ok, _ := regexp.MatchString(pat, searchIn)
|
||||||
```
|
```
|
||||||
|
|
||||||
更多方法中,必须先将正则通过 `Compile` 方法返回一个 Regexp 对象。然后我们将掌握一些匹配,查找,替换相关的功能。
|
更多方法中,必须先将正则模式通过 `Compile` 方法返回一个 Regexp 对象。然后我们将掌握一些匹配,查找,替换相关的功能。
|
||||||
|
|
||||||
示例 9.2 [pattern.go](examples/chapter_9/pattern.go):
|
示例 9.2 [pattern.go](examples/chapter_9/pattern.go):
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user