开发者

Regex to remove non-URL friendly characters, but allow Unicode and accents

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?

Thanks, Mark


How about instead of using a negated class, you simply have a replacement list of the characters you dont want?

s/[:,<]*//g


Microsoft.Security.Application.AntiXss.GetSafeHtml() solved my problem.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜