Math operations in regex

后端 未结 3 1279
予麋鹿
予麋鹿 2020-11-27 06:58

I need to add a number to a backreference while doing a replace operation.

e.g. I am rewriting a URL

www.site.com/doc.asp?doc=321&language=1
         


        
3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-27 07:18

    If you only have a few articles you could just brute force it

    ...doc=322 -> www.site.com/headline/100322.article
    ...doc=323 -> www.site.com/headline/100323.article
    ...doc=324 -> www.site.com/headline/100324.article
    ...etc
    

    Math in regex, you see it here first.

提交回复
热议问题