I want to match a pattern like this %data% in a string.
Although it can be easy but i need solution that can be robust for a big and multiline string.
For e.g.: i would like to match only the first and second matching %% combination and third and fourth (etc. etc.) in the following:
this %data% is not %data that i want to % show up in the results. % some more demo text %
I would like to match only the parts
%data%
,
%data that i want to %
,
% some more demo text %
from the above string..
I have tried:
I was trying to use this pattern but its selecting all of it from the first % to the last % symbol..
/^\%[\s\S]*\%$/gm
If this question has been asked and you want to close it.. just point me in the right direction and close it if you want.. thanks.
it is not the same question as marked by many.. with the title:
Regex Match all characters between two strings
and url: url as it is normal regular expression and not the one in JS (as JS doesn't support lookbehind) and it doesn't have the pair matching problem as mine.. hence, its completely different i think..
I would really like a good description of the RegEX if someone can provide it with the answer.. as i am not well versed in reading much complicated RegEx's, just getting used to it.. and i would also like an explanation of why my code is breaking and doesn't work to help me in future..