This article introduces you to the link address of the SRC attribute value if you get the picture from IMG.
The string to match:
Regular Expressions:
[^ '" "]*) [\ '"]) | (? <src>[^\s]*))
Regular match output results:
Ximage/ad1.gifimage/ad2.gif
PHP regular extract or the SRC attribute value of the IMG element:
<?php/*php Extract any attribute in the IMG tag */$str = ' <center>php extract or change any of the attributes in the IMG tag of the image </center> '; 1, take the entire picture code Preg_match ('/<\s*img\s+[^>]*?src\s*=\s* (\ ' |\ ') (. *?) \\1[^>]*?\/?\s*>/i ', $str, $match); echo $match [0]; 2, take width preg_match ('//i ', $str, $match); echo $match [1]; 3, take height Preg_match ('//i ', $str, $match); echo $match [1]; 4, take src preg_match ('//i ', $str, $match); echo $match [1]; /*php Replace any attribute *///1 in the image img tag, replace src= "/uploads/images/20100516000.jpg" with src= "/uploads/uc/images/20100516000.jpg") Print Preg_replace ('/()/I ', "\${1}uc/images/\${3}", $STR); echo "
JS Regular expression Extract image address
Regular Expressions <script language= "JavaScript" >
var a= ' <p></P>"
var b=//gi var s=a.match (b) for (Var i= 0;i<s.length;i++) {alert (s[i]); alert (regexp.$1)} </script>