lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Thank you all for the response. Now, I have multiple options to choose from J.

 

From: lua-l-bounces@lists.lua.org [mailto:lua-l-bounces@lists.lua.org] On Behalf Of Aapo Talvensaari
Sent: Tuesday, October 28, 2014 11:20 AM
To: Lua mailing list
Subject: Re: String to Hexadecimal Conversion

 

On Oct 27, 2014 5:55 PM, "Jain, Punit" <Punit.Jain@emc.com> wrote:
> How can I check whether a string is a hexadecimal number or not? E.g. “0x123” is a hex string, but “123” and “xyz” are not.

How about:

if (("0x123"):find("0x", 1, true)) == 1 and tonumber("0x123") then ...