正则表达式 php

来源:百度知道 编辑:UC知道 时间:2024/05/21 16:46:02
请问下面的程序:
preg_match("/^(http:\/\/)?([^\/]+)/i","http://www.php.net/index.html",$matches);
上面的结果中: $matches[0];$matches[1];$matches[2]中的内容为什么?
那个正则表达式子是什么意思?/^(http:\/\/)?([^\/]+)/i
从?以后就看不懂了!!

?之后是匹配不含/符号的,也就是到/index.html之前
用print_r可以知道$matches数组,例如
<?php
preg_match("/^(http:\/\/)?([^\/]+)/i","http://www.php.net/index.html",$matches);
print_r($matches);

我回答过你一个了 ...?