如何用Perl匹配url根目录
来源:百度知道 编辑:UC知道 时间:2024/05/26 19:21:09
如题
比如:
http://127.0.0.1/example/abc_.htm/index-.php
要匹配http://127.0.0.1/example/abc_.htm/
而不是http://127.0.0.1/example/
还要匹配如下url的根目录
http://127.0.0.1/exa/a-_.htm/a-b_c.f.php?to=abc/a03-2
使Perl输出如下:
http://127.0.0.1/exa/a-_.htm/
万分感谢!!
比如:
http://127.0.0.1/example/abc_.htm/index-.php
要匹配http://127.0.0.1/example/abc_.htm/
而不是http://127.0.0.1/example/
还要匹配如下url的根目录
http://127.0.0.1/exa/a-_.htm/a-b_c.f.php?to=abc/a03-2
使Perl输出如下:
http://127.0.0.1/exa/a-_.htm/
万分感谢!!
你试试这段代码,其中$m可以赋值为http://127.0.0.1/example/abc_.htm/index-.php
或者
http://127.0.0.1/exa/a-_.htm/a-b_c.f.php?to=abc/a03-2
=============================
$m="http://127.0.0.1/exa/a-_.htm/a-b_c.f.php?to=abc/a03-2";
if($m=~m%(http://127.0.0.1/(.*)?.htm/)%g){
print "$1\n";
=============================
不知道符合不符合你的要求
祝你成功!