如何找到一个字符串是否包含任何特殊字符? [英] How to find whether a string contains any of the special characters?

查看:104
本文介绍了如何找到一个字符串是否包含任何特殊字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想找到一个字符串是否包含任何特殊字符,例如,@,#,$,%,^,&安培;!,*,(,)....等



我怎么能做到这一点不用循环thorugh字符串中的所有字符?


解决方案

 正则表达式RgxUrl =新的正则表达式([^ A-Z0-9]); 
blnContainsSpecialCharacters = RgxUrl.IsMatch(stringToCheck);


I want to find whether a string contains any of the special characters like !,@,#,$,%,^,&,*,(,)....etc.

How can I do that without looping thorugh all the characters in the string?

解决方案

  Regex RgxUrl = new Regex("[^a-z0-9]");
                    blnContainsSpecialCharacters = RgxUrl.IsMatch(stringToCheck);

这篇关于如何找到一个字符串是否包含任何特殊字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆