简体   繁体   中英

RegEx reconstruction with replace with groups

We are doing URL rewrite and user can type url as

 somesite.com/category6/page.aspx

Now we want to rewrite the url as

 somesite.com/6/category/page.aspx.

We already have bunch of regex for url rewrite however replace string is static, we wanted follow the same pattern and not to customize for this particular one.

rewrite rule :

(category)([0-9]+)(/?.*)

parsing :

{R:0} category6/page.aspx

{R:1} category

{R:2} 6

{R:3} /page.aspx

using the rules :

{R:2}/{R:1}{R:3}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM