Sign in to follow this  
Followers 0
Kate

check if a variable is a character

4 posts in this topic

So there's IsInt and IsNumber...I need IsChar or IsCharacter. Just trying to test if a variable is a character A-Z. Is there something I'm missing?

Thanks,

Kate

Share this post


Link to post
Share on other sites



StringIsAlNum

StringIsAlpha

William

Share this post


Link to post
Share on other sites

StringIsAlNum

StringIsAlpha

William

Ah! Thanks! I kept searching for "character" :/ Apparently my search-fu is weak today. Thanks again!

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

You can use this:

ConsoleWrite("1: "& IsCharSet("1") & @CRLF)
ConsoleWrite("A: "&IsCharSet("A") &  @CRLF)
ConsoleWrite("a: "&IsCharSet("a") &  @CRLF)
ConsoleWrite("A1: "&IsCharSet("A1") &  @CRLF)
ConsoleWrite("AA: "&IsCharSet("AA") &  @CRLF)

Func IsCharSet($in, $pattern = "(?i)[^A-Z]")
    If $in = "" Then Return SetError(1, 0, 0) ;input is empty
    Local $aRegEx = StringRegExp($in, $pattern, 3)
    If @error Then Return 1
    Return 0
EndFunc

It may be that there is a much easier way to check this which I don't have in mind currently.

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0