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".
Solution 1:
You can use LINQ:
fullUri.Any(char.IsUpper);
Solution 2:
RegEx seems to be overkill:
bool containsAtLeastOneUppercase = fullUri.Any(char.IsUpper);
Solution 3:
Use Linq!
fullUri.Any(c=> char.IsUpper(c));