科多斯 &“不能指代开放组" [英] Kodos & "cannot refer to open group"

查看:39
本文介绍了科多斯 &“不能指代开放组"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只想匹配 1010 或 0101 而不是 1111 或 0000.我使用以下正则表达式:

I want to only match 1010 or 0101 but nor 1111 nor 0000. I use the following regex :

\b((1|0)(?!\2))+

它在 Kodos 中运行良好,但由于 group(),我也想要匹配的序列.我试过了:

It works well in Kodos but I also want the matched sequence thanks to group(). I've tried :

\b(((1|0)(?!\2))+)

但是在 Kodos 中显示cannot reference open group*"我不明白为什么它不起作用.

but "cannot refer to open group*" is displayed in Kodos and I don't understand why it doesn't work.

请问你能帮我吗?

适当的正则表达式是 (\b(((1|0)(?!\3))+).

The appropriate regex is (\b(((1|0)(?!\3))+).

推荐答案

我认为问题在于您的第二个代码行中有三个独立的组.它们根据开头括号的顺序进行编号.

I believe the problem is that you have three separate groups in your second code line. They are numbered based on the ordering of the opening parens.

Group 1: ((1|0)(?!\2))+
Group 2: (1|0)(?!\2)
Group 3: 1|0

如您所见,第 2 组包含对自身的引用,但在解析时仍处于打开状态.

As you can see, group 2 contains a reference to itself, but it is still open while being parsed.

这篇关于科多斯 &“不能指代开放组"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆