开发者

regular expression part of URL extract

开发者 https://www.devze.com 2023-03-12 03:53 出处:网络
need a little help with extracting part of the URL via regex I have URL which looks like this: http://www.something.com/offer/1/all-[part to be extracted]-offers-discounts

need a little help with extracting part of the URL via regex

I have URL which looks like this:

http://www.something.com/offer/1/all-[part to be extracted]-offers-discounts

First parameter is static/fixed (/offer/开发者_如何学编程), second one is number variable (/1/) which is in range of x-xxxxx.

This needs to be 301 redirected to: http://www.something.com/[part to be extracted]


http://www.something.com/offer/\d+/all-(.*)-offers-discounts

redirect to

http://www.something.com/$1


Split the Incoming url on "/" if using Java use string.split() take the last index of the returned array in a variable say resultSplit, again split resultSplit on "-" take the second index from the result array and use it for redirection on the new url.

0

精彩评论

暂无评论...
验证码 换一张
取 消