在以下情况下,我有一个正常工作的正则表达式,其负前瞻和回溯(?:^_(?!_))(.*)(?:(?<!_)_$)
:
_john_ # matched
_status_ # matched
_aa_ # matched
_a_ # matched
_john_smith_ # matched
_@_ # matched
___test__ # not matched
__john_ # not matched
__john_smith_ # not matched
_john___ # not matched
_john_smith__ # not matched
__john__ # not matched
__john_smith__ # not matched
anything # not matched
我想匹配所有以单个_
开始和结束的情况,所有其他情况都不应匹配。
在golang中,regexp
软件包没有实现超前和回溯。如何将上述正则表达式转换为符合golang的表达式?
非常感谢您的帮助!