preg匹配所有提取功能名称和参数的名称
我有此字符串:
not(matches(#[Sécurité][Alarme][Mode]#, ["Desarmer",{"action":"Desarmer Sys"}]), result).
我想提取函数的名称:不是
,我也想提取功能的参数:
matches(#[Sécurité][Alarme][Mode]#, ["Desarmer",{"action":"Desarmer Sys"}])
result
我尝试过,但它不起作用:
~[\w]+(?:\w+(\([^()]*+(?:(?1)[^()]*)*+\)))+~u
它可以正常工作第一句话,但是,如果我回想起参数的功能 “匹配(#[sécurité] [alarme] [mode]#,[“ desarmer”,{“ action”:“ desarmer sys”}])”我无法获得正确的参数。
这是所有不同参数的列表:
- 匹配(#[sécurité] [armare] [mode]#,[“ desarmer”,“ desarmer sys”]),
- #[sécurité] [armare] [armare] [mode]#,
- “ desarmer” ,
- [“ Test11”,“ Test-12”],
- {“ T1”:“ Test-21”,“ T2”:“ Test22”},
- [“ Test11”,“ Test-12”,{“ T2”: test21“,” T2“:” test-22“}],
- #test#,
- [#[sécurité] [armare] [mode]#”,“ test12”,{“ t3”:“#[sécurité] ] [模式]#,“ T2”:“ test-22”}]]
I have this string:
not(matches(#[Sécurité][Alarme][Mode]#, ["Desarmer",{"action":"Desarmer Sys"}]), result).
And I want to extract the name of the function: not
And I want to extract the parameters of function, too:
matches(#[Sécurité][Alarme][Mode]#, ["Desarmer",{"action":"Desarmer Sys"}])
result
I tried with this but it does not work:
~[\w]+(?:\w+(\([^()]*+(?:(?1)[^()]*)*+\)))+~u
It works fine for the first sentence but, if I recall for function on parameter
"matches(#[Sécurité][Alarme][Mode]#, ["Desarmer",{"action":"Desarmer Sys"}])" I can't obtain the right parameter.
This is a list of all different parameters:
- matches(#[Sécurité][Alarme][Mode]#, ["Desarmer","Desarmer Sys"]),
- #[Sécurité][Alarme][Mode]#,
- "Desarmer",
- ["test11","test-12"],
- {"t1":"test-21","t2":"test22"},
- ["test11","test-12",{"t2":"test21","t2":"test-22"}],
- #test#,
- ["#[Sécurité][Alarme][Mode]#","test12",{"t3":"#[Sécurité][Alarme][Mode]#","t2":"test-22"}]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为对各种元素进行了更仔细的描述(特别是为了避免在字符串内的圆括号之类的陷阱),:
演示
I think a more careful description of the various elements is in order (in particular to avoid pitfalls like round brackets inside a string), :
demo