[英]Regular expression pattern to match URL with or without http://www
[英]URl pattern Matching in php without http or www
我有一個HTML文件,其中包含一些鏈接,例如
<a href="clash/football/a-vs-b">
<a href="clash/football/dsfdsfds-vs-erer">
我用這個$regex_pattern = "/^[^.]+((\\.[^.\\/]{1,3}\\b){1,2}).*$/";
模式來查找這種類型的URL。 但是無法得到這個。 請有人幫我。 我需要匹配"<a href="clash/football/a-vs-b">"
類的總標簽
正則表達式描述了對常規語言的操作,而html
不是常規語言! 使用DomDocument會更好。
然后,您可以查看getElementsByTagName
以獲取所有<a href>
標記。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.