I have to parse this template string variable, for example:
$str = "<p>Don't want to receive email notifications? %%UNSUBSCRIBE['Adjust your message settings']%% values in your privacy.</p>";
开发者_开发问答My result should be this:
"<p>Don't want to receive email notifications? <a href='http://www.example.com/'>Adjust your message settings</a> values in your privacy.</p>"
How to do this in php/regex?
Well heres a regex that matches that placeholder & captures 2 possible variables inside it which you might need:
%%(UNSUBSCRIBE)\[\'(.*?)\'\]%%
Something like preg_replace("/%%(UNSUBSCRIBE)\[\'(.*?)\'\]%%/", "$1$2", $string)
should replace the whole placeholder with just the variables (the $1 and $2 represent the captured matches)...
Good luck!
精彩评论