检测一个字符串包含大写字母 [英] Detect if a string contains uppercase characters
本文介绍了检测一个字符串包含大写字母的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有使用正则表达式来检测,如果一个字符串包含大写字母的方法吗?目前我使用下面的正则表达式:
Is there an alternative to using a regular expression to detect if a string contains uppercase characters? Currently I'm using the following regular expression:
Regex.IsMatch(fullUri, "[A-Z]")
它工作正常,但我经常听到一句古老的格言:如果你使用正则表达式,你现在有两个问题。
It works fine but I often hear the old adage "If you're using regular expressions you now have two problems".
推荐答案
您可以使用LINQ:
fullUri.Any(c => char.IsUpper(c));
这篇关于检测一个字符串包含大写字母的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文