Regex syntax question - trying to understand

Posted by Asaf Chertkoff on Programmers See other posts from Programmers or by Asaf Chertkoff
Published on 2011-06-30T07:54:14Z Indexed on 2011/06/30 8:30 UTC
Read the original article Hit count: 471

Filed under:
|
|

i don't know if this question belong here or no, but it is worth a shot. i'm a self taught php programmer and i'm only now starting to grasp the regex stuff. i'm pretty aware of its capabilities when it is done right, but this is something i need to dive in too. so maybe someone can help me, and save me so hours of experiment.

i have this string:

here is the <a href="http://www.google.com" class="ttt" title="here"><img src="http://www.somewhere.com/1.png" alt="some' /></a> and there is <a href="#not">not</a> a chance... 

now, i need to perg_match this string and search for the a href tag that has an image in it, and replace it with the same tag with a small difference: after the title attribute inside the tag, i'll want to add a rel="here" attribute. of course, it should ignore links (a href's) that doesn't have img tag inside.

help will be appreciated, thanks.

© Programmers or respective owner

Related posts about php

Related posts about regex