Add one space after every two characters and add a character infront of every single character

后端 未结 4 768
甜味超标
甜味超标 2021-01-20 04:05

I want to add one space after every two characters, and add a character in front of every single character.

This is my code:

string str2;
str2 = str1         


        
4条回答
  •  盖世英雄少女心
    2021-01-20 04:25

    [TestMethod]
    public void StackOverflowQuestion()
    {
        var input = "0123457";
        var temp = Regex.Replace(input, @"(.{2})", "$1 ");
        Assert.AreEqual("01 23 45 7", temp);
    }
    

提交回复
热议问题