i’m getting nuts with an regular expression. I have a string like this:
%closed% closed (%closed_percent%\%), %open% open (%open_percent%\%)
What I need is a regular expression that matches the following:
%closed%
%closed_percent%
%open%
%open_percent%
but not the two \%
At the moment I use:
\%([^\%]+)\%
that gives me:
%closed%
%closed_percent%
%), %
% open (%
...
Anyone can help me with that?
The simple way:
Matches:
%foo%Allows (multiple) backslash escapes:
Matches only
barin:\%foo% \\%bar% \\\%baz%…and this allows escapes inside of it too:
Matches:
%foo\%bar%Use the value of the first capturing group with the last two expressions.