PHP extracts the image address [regular expression] from the string. Copy the code as follows :? Php?strpimgsrcupfiles2009071246430143_1.jpg altp; $ pattern [img | IMG]. *? Src [|] (. *? (? : 2.16.gif |. jpg]) [|]. *? []?;
The code is as follows:
$ Str ='
';
$ Pattern = "/<[img | IMG]. *? Src = [\ '| \ "] (. *? (? : [\. Gif | \. jpg]) [\ '| \ "]. *? [\/]?> /";
Preg_match_all ($ pattern, $ str, $ match );
Print_r ($ match );
?>
Result:
Array
(
[0] => Array
(
[0] =>
)
[1] => Array
(
[0] => upfiles/2009/07/1246430143_1.jpg
)
)
The http://www.bkjia.com/PHPjc/324555.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/324555.htmlTechArticle code is as follows :? Php $ str = 'pimg border = "0" src = "upfiles/2009/07/1246430143_1.jpg" alt = "" // P'; $ pattern = "/[img | IMG]. *? Src = [\ '| \ "] (. *? (? : [\. Gif | \. jpg]) [\ '| \ "]. *? [\/]? /";...