Java Url重写正则表达式-不匹配
我有一个用于url重写的正则表达式:Java Url重写正则表达式-不匹配,java,regex,url-rewriting,tuckey-urlrewrite-filter,Java,Regex,Url Rewriting,Tuckey Urlrewrite Filter,我有一个用于url重写的正则表达式: <from>^/page/([0-9]+)/order/(.*)/by/(.*)/composition/(.*)/location/(.*)/price_min/(.*)/price_max/(.*)/industry/(.*)/type/(.*)$</from> <to>/page=$1&order=$2&by=$3&composition=$4&location_id=$5&p
<from>^/page/([0-9]+)/order/(.*)/by/(.*)/composition/(.*)/location/(.*)/price_min/(.*)/price_max/(.*)/industry/(.*)/type/(.*)$</from>
<to>/page=$1&order=$2&by=$3&composition=$4&location_id=$5&price_min=$6&price_max=$7&industry_id=$8&type_id=$9</to>
^/page/([0-9]+)/order/(.*)/by/(.*)/composition/(.*)/location/(.*)/price_-min/(.*)/price_-max/(.*)/industry/(.*)/type/(.*)$
/页面=$1&订单=$2&按=$3&组合=$4&位置id=$5&价格最低=$6&价格最高=$7&行业id=$8&类型id=$9
我想匹配下面的URL,但没有匹配项
/第/2页/订单/id/by/desc/composition/1/location/none/price\u min/2/price\u max/2/industry/2/type/3
考虑使用以下方法:
^/page/([0-9]+)/order/(.+?)/by/(.+?)/composition/(.+?)/location/(.+?)/price_min/(.+?)/price_max/(.+?)/industry/(.+?)/type/(.+?)$
你的正则表达式有两件事:
+
而不是*
,因为/
和/
之间总会有数据李>
?
,这意味着它将是非贪婪的。它相当于写入([^/]+)
,这意味着将/
以外的任何字符多次匹配试着用非贪婪的
*
替换贪婪的*?
哦,好的,谢谢你,我现在更明白了,我今天晚些时候再试试这个好的,很好,谢谢你,我刚刚补充了一件事&应该是&;