写一个正则表达式匹配格式如下:
news/28/Twitter Marketing Tools NO.3.htmlRewriteRule news/([0-9]+)/里面我不会处理"."\.html$ /news.php?id=$1&title=$2
news/28/Twitter Marketing Tools NO.3.htmlRewriteRule news/([0-9]+)/里面我不会处理"."\.html$ /news.php?id=$1&title=$2
例如说,后面的标题肯定是 xxx.html 的????
news\/([0-9]+)\/(?!\.html).*\.html /news.php?id=$1&title=$2
RewriteRule news/([0-9]+)/(.*?)\.html$ /news.php?id=$1&title=$2
由于在“.thml”之前出现了“.”号会比较麻烦点。
$str_text = ""; /*这里存储着你要替换的字符串*/
$str_pattern="/
\w+ /*匹配一个单词*/
\/
[1-9][0-9]* /*匹配数字*/
\/
[^\.]+((?!\.html) \.[^\.]+) /*匹配.thml之前的字符串*/
\.html /*匹配最后的.html*/
/x";
if (preg_match($str_pattern,$str_text[,$a_matches]))
{
/*匹配成功时执行的动作,如果启用了后面的中括号中的参数的话,匹配的结果就会保存在
$a_matches中,你可以根据需要在正则表达式中添加捕获型括号,这样结合$a_matches参数就可
以得到很多内容了。这时其实也可以采用命名捕获{语法规则:(?<name>expression)或者
(?'name'expression)}机制,这样在$a_matches数组中就会存储相就应的关联元素。*/
}
else
{
/*匹配失败时执行的动作*/
}