A regex to match a string that is surrounded by %
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?
精彩评论