I have a text that has multiple occurrences of variables in this format:
Example text will %%include%% these %%parameters%%
I'm trying to use this:
preg_match('/%%[\s\S]*?%%/i',$output, $matches);
But for some reason I'm getting only the first match, any ideas?
[\s\S]
in PHP (as opposed to JavaScript). A simple.
is enough when you set the/s
option. Also, you don't need the/i
option because there are no cased characters in your regex anyway:'/%%.*?%%/s'
will do (together withpreg_match_all()
). – Tim Pietzcker