Test for number or letters in a string

Is there a function or an easy test to determine if a string starts with a number or a letter?

beginswith

I think you mean any letter or any number? You would use the rangematch( function and a text funnel. If your string is in mystring, this formula will be true if mystring starts with a letter.

rangematch(mystring[1,1],"AZaz")

This formula will be true if mystring starts with a numeric digit.

rangematch(mystring[1,1],"09")

This formula will be true if mystring starts with a letter or a numeric digit.

rangematch(mystring[1,1],"AZaz09")

Much thanks for the response. Rangematch( is new to me.

rangematch( has the disadvantage that you have to specify each range of consecutive Unicode values separately, e.g. "AZaz" to cover the 52 alphabetical characters contained in two blocks in 7-bit ASCII. To extend that to the further 62 in the Latin 1 supplement you’d have to specify a further three blocks (“AZazÀÖØöøÿ”), and even then you don’t have complete coverage of the characters needed for the major western European languages — let alone the rest that use the Latin alphabet or the many other alphabets of the world.

Regular expressions are much better for this. To test for the presence of any alphabetical character in a string use:

if string regexmatch "\p{L}" ...

To test for either a letter or an arabic numeral (0123456789: ASCII 48–57) use:

if string regexmatch "[\p{L}\d]" ...

And to test for a letter or arabic numeral as the first character of a string use:

if string regexmatch "^[\p{L}\d]" ...

Or to test for a letter or arabic numeral as the last character of a string use:

if string regexmatch "[\p{L}\d]$" ...

To extend that to match any numeral in any number system, replace \d with \p{N}

To me as well.

I would’ve gone to ?(striptonum(mystring[1,1]) = “”,“Alpha”,“Num”)