Replace single backslash with double backslash

前端 未结 5 2149
隐瞒了意图╮
隐瞒了意图╮ 2020-12-18 18:59

It seems simple enough, right? Well, I don\'t know.

Here\'s the code I\'m trying:

input = Regex.Replace(input, \"\\\\\", \"\\\\\\\\\\\\\");
         


        
5条回答
  •  隐瞒了意图╮
    2020-12-18 19:26

    If you intend to use the input in a regex pattern later, it can be a good idea to use Regex.Encode.

    input = Regex.Escape(input);
    

提交回复
热议问题