C# regex to remove non - printable characters, and control characters, in a text that has a mix of many different languages, unicode letters

后端 未结 3 1975
天命终不由人
天命终不由人 2020-12-03 07:45

i would appreciate your help on this, since i do not know which range of characters to use, or if there is a character class like [[:cntrl:]] that i have found in ruby?

3条回答
  •  悲&欢浪女
    2020-12-03 08:16

    To remove all control and other non-printable characters

    Regex.Replace(s, @"\p{C}+", String.Empty);
    

    To remove the control characters only (if you don't want to remove the emojis

提交回复
热议问题