对于以下情况,我有一个可以工作的正则表达式,它具有负向前视和后视(?:^_(?!_))(.*)(?:(?<!_)_$):
_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兼容的正则表达式?
任何帮助都是非常感谢的!
发布于 2019-02-14 11:52:25
https://stackoverflow.com/questions/54682798
复制相似问题