【发布时间】:2018-11-29 18:50:30
【问题描述】:
有效示例
12[red,green],13[xs,xl,xxl,some other text with chars like _&-@#%]
number[anythingBut ()[]{},anythingBut ()[]{}](,number[anythingBut ()[]{},anythingBut ()[]{}]) or nothing
Full match 12[red,green]
Group 1 12
Group 2 red,green
Full match 13[xs,xl,xxl,some other text with chars like _&-@#%]
Group 1 13
Group 2 xs,xl,xxl,some other text with chars like _&-@#%
无效示例
13[xs,xl,xxl 9974-?ds12[dfgd,dfgd]]
我尝试的是:(\d+(?=\[))\[([^\(\[\{\}\]\)]+)\],regex101 link with what I tried,但这也匹配示例中给出的错误输入。
【问题讨论】:
-
你对
13[xs,xl,xxl 9974-?ds12[dfgd,dfgd]],12[red,green]有什么期望? -
不匹配(如果可能)或匹配正确语法的匹配
12[red,green]
标签: php regex validation url preg-match