开发者

A regex to match a string that is surrounded by %

开发者 https://www.devze.com 2023-02-07 04:17 出处:网络
i need a regex to 开发者_开发知识库find all string that is surrounded by % example: A=%Test1% OR B = %Test2% AND (C=%Test3

i need a regex to 开发者_开发知识库find all string that is surrounded by %

example:

A=%Test1% OR B = %Test2% AND (C=%Test3 OR C = %Test4)

what i need are the strings:

%Test1%, %Test2%, %Test3% and %Test4%

thanks.


Just use

%[^%]+%

Which matches a percent sign, followed by a non-zero number of non-percent characters and another percent.


Maybe %[[:alnum::]+% would do the job?

0

精彩评论

暂无评论...
验证码 换一张
取 消