Reputation: 6884
I have this regex for an url rewriting:
<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>
I want to match an URL like the below one, but there is no match.
/page/2/order/id/by/desc/composition/1/location/none/price_min/2/price_max/2/industry/2/type/3
Upvotes: 0
Views: 577
Reputation: 29823
Consider using the following one:
^/page/([0-9]+)/order/(.+?)/by/(.+?)/composition/(.+?)/location/(.+?)/price_min/(.+?)/price_max/(.+?)/industry/(.+?)/type/(.+?)$
Two things with your regex:
.+
instead of .*
, since there will always be data between /
and /
. ?
, which means that it will be non-greedy. It is the equivalent as writing ([^/]+)
instead, which means match any character multiple except /
multiple times.Upvotes: 1