Remove all whitespace from C# string with regex

前端 未结 7 1562
遇见更好的自我
遇见更好的自我 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 11:05

    Using REGEX you can remove the spaces in a string.

    The following namespace is mandatory.

    using System.Text.RegularExpressions;
    

    Syntax:

    Regex.Replace(text, @"\s", "")
    
    0 讨论(0)
提交回复
热议问题