PHP regular expression find and append to string
Posted
by Gary
on Stack Overflow
See other posts from Stack Overflow
or by Gary
Published on 2010-03-31T05:01:25Z
Indexed on
2010/03/31
5:03 UTC
Read the original article
Hit count: 386
I'm trying to use regular expressions (preg_match and preg_replace) to do the following:
Find a string like this:
{%title=append me to the title%}
Then extract out the title
part and the append me to the title
part. Which I can then use to perform a str_replace(), etc.
Given that I'm terrible at regular expressions, my code is failing...
preg_match('/\{\%title\=(\w+.)\%\}/', $string, $matches);
What pattern do I need? :/
© Stack Overflow or respective owner