前面我們都是在整個(gè)輸入的字符串中做匹配憨琳,而沒有考慮在字符串中的哪個(gè)具體的位置做匹配辅髓,比如只在行首做匹配株灸,只在行末做匹配吼和。Boundary matcher就是用來限定匹配位置的。
Boundary Construct | Description |
---|---|
^ | The beginning of a line |
$ | The end of a line |
\b | A word boundary |
\B | A non-word boundary |
\A | The beginning of the input |
\G | The end of the previous match |
\Z | The end of the input but for the final terminator, if any |
\z | The end of the input |
需要注意^和\A的區(qū)別句伶,因?yàn)檩斎肟赡懿恢挂恍小?/p>
Boundary Matcher