Re: preg guru question
| From: | André Cerqueira | Date: | Sat, 14 Feb 2004 01:09:02 +0000 |
| Subject: | Re: preg guru question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-177667@lists.php.net to get a copy of this message | ||
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
did you post the same message 7 times?
try:
<?
$subject = '<img src="THIS12BIT.ext">';
$pattern = '/<img[\s]+?src=[\'"](.+?)[\'"].*?>/i';
$matchFound = preg_match_all ($pattern, $subject, $matches, PREG_SET_ORDER);
print_r($matches);
//$matches[$i][1] is what really matters
?>
that pattern may not be the best regex to use, but i think it works for most cases
Pete M wrote:
Im trying to scan a file and lift the image name from the <img tag ie <img src="THISBIT.ext"> where there could be ' or " I messed around but am 2 embarassed to post code cos it dont work ;-( thanks in advance pete -----BEGIN PGP SIGNATURE-----Version: GnuPG v1.2.4 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFALXUxaxdA/5C8vH8RAtlAAKDUHsfEXVlKDZJRAg0I22rtpJxmsQCgjmze xBmlxQW6SbHMaHV+A/dGydA= =uxyA -----END PGP SIGNATURE-----