Home All Groups Group Topic Archive Search About

Check if string contain Uppercase.

Author
2 May 2007 2:43 PM
Ken
Is there a way if a string contain upper cas letter?
Is there a way if a string contain Numbers?
Is there a way if a string contain (Puntuation/Symbols) such as ~,!,#,$....?

Thanks

Author
2 May 2007 3:01 PM
rowe_newsgroups
On May 2, 10:43 am, "Ken" <k***@jeromegroup.com> wrote:
> Is there a way if a string contain upper cas letter?
> Is there a way if a string contain Numbers?
> Is there a way if a string contain (Puntuation/Symbols) such as ~,!,#,$....?
>
> Thanks

Regex can do all of this. I typed these patterns on-the-fly so they
may not be perfect:

        Dim theString As String = "$10 = Ten Dollars"

        If Regex.IsMatch(theString, "[A-Z]") Then MsgBox("Has Capital
Letter(s)")

        If Regex.IsMatch(theString, "\d") Then MsgBox("Has Numbers")

        If Regex.IsMatch(theString, "[^\w\d\s]") Then MsgBox("Has
Symbols")

Thanks,

Seth Rowe
Author
2 May 2007 6:31 PM
Mattias Sjögren
>        If Regex.IsMatch(theString, "[A-Z]") Then MsgBox("Has Capital
>Letter(s)")

[\p{Lu}] would be more i18n friendly.


Mattias

--
Mattias Sjögren [C# MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.