此双车把模式在以下情况下不起作用
我已经为此创建了正则模式:{{{}} - {{}} - {{}}}}
(?<![^*])(^| [^{^{]) }]*\} \}(?!\})([ - ] {1} \ {\ {\ {[^{}]*\} \} \} \}(?!\}){2}(?! ])
双手柄条重复3次,两者之间的破折号。
但是,以下情况的正则表达式失败了:
- {{}} - {{}}} - {{}}}
ie,即使存在一个dash( - ),该模式也匹配了( - )第一个双车把。理想情况下不应该。
I have created regex pattern for this: {{}}-{{}}-{{}}
(?<![^*])(^|[^{])\{\{[^{}]*\}\}(?!\})([-]{1}\{\{[^{}]*\}\}(?!\})){2}(?![^*])
Double handle bars repeated exactly 3 times with dashes in between.
But the regex pattern is failing for the following case:
-{{}}-{{}}-{{}}
i.e., the pattern is matching even though a dash(-) is present before the first double handlebars. It ideally shouldn't.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此部分
(?在模式末尾的负面lookahead中),
相反,您可以在左侧和右侧主张白色空间边界。
请注意,此部分
[ - ] {1}
可以写为-
请参阅a Regex101演示。
This part
(?<![^*])
means that these should not be a char other than*
directly to the left of the current position (which is also used in the negative lookahead at the end of the pattern)Instead you can assert a whitspace boundary to the left and to the right.
Note that this part
[-]{1}
can be written as just-
See a regex101 demo.