preg_replace('/<xs:element name="(.*)" maxOccurs="unbounded">/',"<xs:element name=".$new." maxOccurs="unbounded">",$str)$str 就是替换后的结果
是哪方面的,例如:在html中查找url的正则表达式. isapi url中的汉字用正则表达式去写.
preg_replace('^/(\w{2})/(\w{2})/img.jpg^','$1/$2/img-lp.jpg','/aa/bb/img.jpg');
^<?php$str = '<p></p><img src="1.jpg"><img src="2.jpg" alt="2.jpg">';preg_match_all('/<img[^1653>]*?src="([^"]*)"[^>]*?\s+alt="[^"]*"[^>]*>/is', $str, $matches);print_r($matches);exit;
$str = "{dede:img text='' width='151' height='202'}./images/adas.jpg{/dede:img}";preg_match('/\{dede:.+\}(.+)\{\/dede:.+\}/',$str,$arr);print_r($arr);测试均OK.如果这个答案帮助到了您,请不要忘了采纳哦!谢谢
如果这些是单词 ,加上个 \bass\b 加上个\b 锚点匹配[\S]与[\s]空白与非空白的边界就能只匹配 ass 不会匹配 class
preg_replace('/\[(?<key>.+?)\].+?\[\/\k<key>\]/is','',$str);
$string = '/aa/bb/img.jpg';preg_replace("/([^\/]+)\/([^\/]+)\/([^\.]+)\.(.*)$/", "\$1/\$2/\${3}-lp.\$4", $string);
if(!preg_match("/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/", $ip)) { return 'IP Address Error'; }
用substr也可以,判断第一位是不是0就行