Regular expression problem (PHP)
Posted
by Marcos
on Stack Overflow
See other posts from Stack Overflow
or by Marcos
Published on 2010-05-06T17:16:15Z
Indexed on
2010/05/06
17:18 UTC
Read the original article
Hit count: 267
Hello all. I have a little problem with my regular expression, that I use in PHP. My code identify all tags of my content and add a link in this image. My code is working when I use dinamycally, without any defined image. When I try with a imapge path, the code does not work. How can I solve this problem?
Working code:
$content = preg_replace('/(<img .*?src="(.+?)".*?>)/','<a class="nyromodal foto" href="'.$imagem_wordpress.'">\1</a>', $content);
Problem code:
$content = preg_replace('/(<img .*?src="ttp://mysite.com/files/2010/04/bac-gallery-site-matters-saline-project1.jpg".*?>)/','<a class="nyromodal foto" href="'.$imagem_wordpress.'">\1</a>', $content);
© Stack Overflow or respective owner