Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regex.Match Uppercase

Tags:

regex

Is there any way when using .net's Regex.Match() to work out if a string only contains capitals?

I am working in an application (so I don't have access to the code) which allows me to see if a field matches a certain regex pattern (using Regex.Match() behind the scene). So I want to use this to work out if the string is only capitals.

Thanks!

like image 276
Richard Avatar asked Sep 15 '25 05:09

Richard


1 Answers

You can use the following regex. This will match any uppercase letter that has a lowercase variant.

^\p{Lu}+$

Or you can simply match only uppercase letter characters.

^[A-Z]+$
like image 107
hwnd Avatar answered Sep 17 '25 19:09

hwnd