Quick note: I AM SO NOT A REGEX DUDE.
So here is what I need... say I have the following string (coming from a database):
Code: Select all
<?php
$string = 'Some text here for example <a href="image.png" /><img src="../image-small.png" /></a>
<p>And some more text so that you can <a href="morelinkage.php">See Links</a>.</p>
<p>And another example <a href="fields">Another one</a></p>';
?>I also need this to fetch the values I am looking for even if the markup is malformed or variant, so if the markup looks like <a href = mingleme.php> it would still catch it. SO....
In my example above I would expect to retrieve the following:
image.png
morelinkage.php
What is working for me (thanks to pickle) as long as there are no slashes or dots before the value, is:
Code: Select all
<?php
$pattern = '/<img.*?src[ ]*=["\' ]*([\w\.]*).*>/i'; // pickles
?>Help me DevNet Regex gurus. You're my only hope.