Hi there,
I’m new to regular expressions. I’d really appreciate it if anyone could offer some assistance on a presumably simple regular expression that I can’t seem to figure out.
I’m looking to insert a raquo just before the </p> of the last paragraph in a string to suggest that an article is continued. In so many words, I’d like…
[code]
<p>This is the first paragraph.</p>
<p>This is the second and last paragraph.</p>
… to become…
[code]
<p>This is the first paragraph.</p>
<p>This is the second and last paragraph. »</p>
I’ve been using preg_replace in an attempt to accomplish this seemingly simple task, but to little avail. Apparently it applies to some strings, but not all – I’ve no idea why.
[code]preg_replace(“/(.*)</p>$/”, “$1 »</p>”, $entry->introduction);
If anyone could shed some lights on why exactly the pattern needs to be enclosed in / as well, I’d appreciate.
Thanks! π