How can you strip non-ASCII characters from a string? (in C#)

前端 未结 11 1394
迷失自我
迷失自我 2020-11-22 17:24

How can you strip non-ASCII characters from a string? (in C#)

11条回答
  •  爱一瞬间的悲伤
    2020-11-22 17:38

    I used this regex expression:

        string s = "søme string";
        Regex regex = new Regex(@"[^a-zA-Z0-9\s]", (RegexOptions)0);
        return regex.Replace(s, "");
    

提交回复
热议问题