Forum Moderators: coopster

Message Too Old, No Replies

preg match and img tag

         

powerflash

1:41 pm on Oct 2, 2008 (gmt 0)

10+ Year Member



I use this code for strip a url in SRC attrib

$pattern = '/<\s*img [^\>]*src\s*=\s*[\""\']?([^\""\'\s>]*)/i';

but if in url is present an blank char this script don't work

example:

http://www.example.com/images2008/nintendo/mm_pack%20docomodake.jpg

preg_match return this :

http://www.example.com/images2008/nintendo/mm_pack (is broken)

[edited by: eelixduppy at 3:14 pm (utc) on Oct. 2, 2008]
[edit reason] exemplified [/edit]

eelixduppy

5:52 am on Oct 6, 2008 (gmt 0)



Before you do the preg_match on the string, use urlencode on the string. I believe that should do the trick:

preg_match($pattern, [url=http://www.php.net/urlencode]urlencode[/url]($string));