Detect if a string contains uppercase characters

前端 未结 7 912
孤城傲影
孤城傲影 2021-01-17 09:32

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:

<         


        
相关标签:
7条回答
  • 2021-01-17 10:00

    Your regex will only find ASCII uppercase letters. Conveniently, the .NET regex engine is Unicode-aware, enabling you to do

    Regex.IsMatch(fullUri, @"\p{Lu}") 
    

    although I suppose that in your case you're not expecting non-ASCII letters in your string (considering its name).

    0 讨论(0)
提交回复
热议问题