Remove all whitespace from C# string with regex

前端 未结 7 1568
遇见更好的自我
遇见更好的自我 2020-12-25 10:18

I am building a string of last names separated by hyphens. Sometimes a whitespace gets caught in there. I need to remove all whitespace from end result.

Sample strin

7条回答
  •  温柔的废话
    2020-12-25 10:54

    Why use Regex when you can simply use the Trim() method

    Text='<%# Eval("FieldDescription").ToString().Trim() %>'
    

    OR

    string test = "Testing    ";
    test.Trim();
    

提交回复
热议问题