當前位置:首頁 » 編程語言 » php匹配url

php匹配url

發布時間: 2022-04-02 12:25:35

1. php如何使用正則表達式匹配url圖片啊

可以這樣:

$image="http://xxxxxxxxx.jpg"
preg_match("/(http://)?w+.jpg/",$image,$matches);//http://可要可不要
echo$matches[0];//$matches[0]即為匹配的圖片路徑

以上只是匹配jpg類型的圖片

如果要匹配其他類型可以這樣使用

preg_match("/(http://)?w+.(jpg|jpeg|gif|png)/",$image,$matches);
echo$matches[0];

2. 求一個PHP匹配URL的正則表達式

\/main.*info3=\d

3. php匹配URL 必須包含字串怎麼寫啊

是要提取額網頁URL中含有&ct=1還是你要提取的<a> 標簽中還有的href含有那個參數?說的具體點吧,呵呵

4. php 正則表達式 url匹配

1,preg_grep(pattern,array);它的返回值是一個新數組,新數組的元素是成功匹配的元素。

5. php 如何根據一個人url獲取跳轉後的url

直接javascript中給獲取的url發送http請求,獲取返回的結果,拿到中間的url地址。

6. PHP-php中如何使用正則表達式匹配URL中的域名

<?php
//從URL中取得主機名
preg_match("/^(http://)?([^/]+)/i","IP/index.html",$matches);
$host=$matches[2];
//從主機名中取得後面兩段
preg_match("/[^./]+.[^./]+$/",$host,$matches);
echo"domainnameis:{$matches[0]} ";
?>

7. php正則匹配查找url

<?php
//需要匹配的字元串。
$content='您在主題<ahref="forum.php?mod=redirect&goto=findpost&pid=236803&ptid=70067"target="_blank">bameimiji</a>的帖子被<ahref="home.php?mod=space&uid=26">站長</a>評分金錢+3<divclass="quote"><blockquote>神馬都是浮雲</blockquote></div>';

if(preg_match("/.*站長[^>]*>([^<]*錢([^<]*))<.*/gi",$content,$m))
{
echo"結果是:".$m[1]." ";
echo"結果是:".$m[2]." ";
}
?>

8. php 正則表達式 提取指定超鏈接中的url

preg_match_all('/<a[^>]+href="([^"]+)"[^>]+class="green"
[^>]+/Ui', $str, $arr);

print_r($arr[1]);

9. 求個php正則匹配url

[a-zA-z]+://[^s]*

熱點內容
為啥編程廣告 發布:2025-07-04 07:30:01 瀏覽:567
資料庫備機 發布:2025-07-04 07:30:00 瀏覽:530
靜態內部類java 發布:2025-07-04 07:25:45 瀏覽:232
玉林電信dns伺服器地址 發布:2025-07-04 07:17:34 瀏覽:437
用鏡像壓縮 發布:2025-07-04 07:17:31 瀏覽:635
lgg3如何設置鎖屏密碼 發布:2025-07-04 06:41:39 瀏覽:346
sqlserver2005命令 發布:2025-07-04 06:27:08 瀏覽:734
壓縮文件啥樣 發布:2025-07-04 06:21:42 瀏覽:300
linux的回車換行 發布:2025-07-04 06:21:39 瀏覽:134
c語言的窗口 發布:2025-07-04 06:20:54 瀏覽:985