https://groups.google.com/forum/#!topic/golang-nuts/7qgSDWPIh_E
that (?!re) regular expression is not supported neither in re2 nor in Google Go. Is there any chance that its support will be implemented in future releases? (it is supported at least in Ruby, Python, Java, Perl)
go-issues:18868 regexp: support lookaheads and lookbehinds
Golang doesn't support positive lookbehind assertion?
支持的场景: https://github.com/google/re2/wiki/Syntax要求makes a single scan over the input and runs in O(n) time
The lack of generalized assertions, like the lack of backreferences, is not a statement on our part about regular expression style. It is a consequence of not knowing how to implement them efficiently. If you can implement them while preserving the guarantees made by the current package regexp, namely that it makes a single scan over the input and runs in O(n) time, then I would be happy to review and approve that CL. However, I have pondered how to do this for five years, off and on, and gotten nowhere.
包含在一传字符串中的手机号,类似abcd13566778888xyz
这样的手机号码前后不包含数字
的正则在Go语言里是不支持的。因为无法一次扫描并在O(n)的时间
里完成。
(?=re)
before text matching re
(NOT SUPPORTED)
(?!re)
before text not matching re
(NOT SUPPORTED)
(?<=re)
after text matching re
(NOT SUPPORTED)
(?<!re)
after text not matching re
(NOT SUPPORTED)
网友评论