简体   繁体   English

如何匹配以下正则表达式php

[英]How to match the following regex php

I want to write a regex to match only the first and last strings below. 我想编写一个正则表达式以仅匹配下面的第一个和最后一个字符串。 So far, I got this regex 到目前为止,我得到了这个正则表达式

%[\w]+@\{[\w"]+\}%

but it wont match anything: 但它不会匹配任何东西:

%adasda@{"asdas":"asdas"}% // should match
5% ashdgasjhdgas % //no match
5%ahsdjhasj % // no match
%asdasdas% //should match

希望对您有所帮助:

^%\w+(@[\{"\w\}:]+)*%$

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM