Why is “$1” ending up in my Regex.Replace() result?

后端 未结 4 709
北恋
北恋 2021-01-17 22:10

I am trying to write a regular expression to rewrite URLs to point to a proxy server.

bodystring = Regex.Replace(bodystring, \"(src=\'/+)\", \"$1\" + proxySt         


        
4条回答
  •  野的像风
    2021-01-17 22:30

    In the second version, I guess proxyStr appears twice because you're inserting it once more. Try

    string s2 = Regex.Replace(s, "((?<=src='/+))", proxyStr);
    

提交回复
热议问题