jberlinsky Posted September 6, 2006 Share Posted September 6, 2006 I have been TRYING to use preg_replace()...it doesnt give me the right resultOBJECTIVE: change <img src=BLAH alt=x> to <img src=BLAH alt=y>ATTEMPTED SYNTAX: $post['post'] = preg_replace("/<img src=[(.+?)] alt=x>/","<img src=\\1 alt-y>",$post['post']); Link to comment https://forums.phpfreaks.com/topic/19909-preg_replace-question/ Share on other sites More sharing options...
effigy Posted September 6, 2006 Share Posted September 6, 2006 [code]<pre><?php $string = '<img src=BLAH alt=x>'; echo preg_replace('/(<img src=(?:.+?) alt=)x>/', '\1y>', $string);?></pre>[/code] Link to comment https://forums.phpfreaks.com/topic/19909-preg_replace-question/#findComment-87172 Share on other sites More sharing options...
Nicklas Posted September 6, 2006 Share Posted September 6, 2006 Or[code=php:0]preg_replace('/(<img.*?alt=).*?>/is', '\\1y>', $string);[/code] Link to comment https://forums.phpfreaks.com/topic/19909-preg_replace-question/#findComment-87184 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.