我正在尝试匹配类型定义。
def euro : t1 -> t2 -> t3 (and this pattern my repeat further in other examples)
我想出了这个正则表达式。
^def ([^\s]*)\s:\s([^\s]*)(\s->\s[^\s]*)*
尽管它匹配了euro
和t1
,但接下来它
- 与
-> t2
匹配而不是t2
- 无法匹配任何带有
t3
的内容
我不知道自己做错了什么,我的目标是捕获
euro t1 t2 t3
作为四个单独的项目,我目前得到的是:
0: "def euro : t1 -> t2 -> t3"
1: "euro"
2: "t1"
3: " -> t3"
t2
和子字符串-> t2
?你想要将t2
放在自己的捕获组中吗? - CertainPerformance