作者knives ()
看板PHP
标题[问题] 这个正规表达式该怎麽改才对
时间Mon Sep 6 16:00:32 2010
※ [本文转录自 RegExp 看板 #1CX9qv6T ]
作者: knives () 看板: RegExp
标题: [问题] 这个正规表达式该怎麽改才对
时间: Mon Sep 6 15:50:14 2010
我现在想要取得网页的 a tag 的href
我现在是用这个正规表达式
href[\s]?=[\s\"\'](http:\/\/|https:\/\/)*(.*?)[\"\']
我希望只取代那些没有加上http://或https:// 这些协定的
举例下面的字串
这是<a href="xxx.php">相对连结</a>
那是<a href="
http://testmysite/xxx.php">绝对连结 </a>
我希望只取代第一个xxx.php,而不会取代到第二个
http://testmysite/xxx.php连结
请问我原来的正规表达式该怎麽改才对
谢谢
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 122.117.39.194
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 122.117.39.194
1F:推 alpe:href[\s]?=[\s\"\'](http:\/\/|https:\/\/)?(.*?)[\"\'] 09/08 16:15