I have the following regex:
我有以下正则表达式:
foo = Regex.Replace(foo, @"[^a-zA-Z0-9\s-]", " ");
Currently, this removes Unicode characters. What regex can I use remove all non-URL friendly characters (i.e. : , < etc.), but allow Unicode and accented characters?
目前,这将删除Unicode字符。我可以使用什么正则表达式删除所有非URL友好字符(即:, <等),但允许unicode和重音字符?< p>
Thanks, Mark
谢谢,马克
2 个解决方案
#1
2
How about instead of using a negated class, you simply have a replacement list of the characters you dont want?
怎么样而不是使用否定的类,你只需要一个你不想要的字符的替换列表?
s/[:,<]*//g
#2
1
Microsoft.Security.Application.AntiXss.GetSafeHtml()
solved my problem.
Microsoft.Security.Application.AntiXss.GetSafeHtml()解决了我的问题。
#1
2
How about instead of using a negated class, you simply have a replacement list of the characters you dont want?
怎么样而不是使用否定的类,你只需要一个你不想要的字符的替换列表?
s/[:,<]*//g
#2
1
Microsoft.Security.Application.AntiXss.GetSafeHtml()
solved my problem.
Microsoft.Security.Application.AntiXss.GetSafeHtml()解决了我的问题。