Hello folks,
I'm desparately trying to find the correct regex for automatically
surrounding every <img>-tag with a hyperlink using PHP's preg_replace
(which uses PCRE).
The catch is not to find the <img ...>-occurrences and surround them
with a hyperlink, the problem is NOT TO do it, when the <img>-tag
ALREADY IS surrounded by a hyperlink.
The pattern I use is the following:
/(<img.*?[^>]*>)/i
This gives me a fine backreference to every single <img>-tag in my
string. But this pattern SHOULD NOT match, when right in front of the
"<img ...>" comes a ">" or else when right behind the <img ...> comes a "<".
I have tried to use patterns like e.g. /(<img.*?[^>]*>)[^<]/i, but this
doesn't help anything -- after hours of try and error I have decided to
give this list a try.
Any help/comment really appreciated!
Regards, Roman.