Oscar Foley
Oscar Foley

Reputation: 7025

What is the ECL equivalent of NaN or IsNumeric?

I want to check if some value (i.e: 42 or 41.0005) is a number in ECL (HPCC). I have in mind a function using Regular Expressions like this:

EXPORT IsNumeric(STRING UniqueID) := FUNCTION
        regex:='^\\d+$';       
        RETURN REGEXFIND(regex, UniqueID);    
END;

Is there a built-in IsNumeric function?

If not... Is there any better way of doing it than using regex? (Thinking both in readability and performance)

NOTE: Seems that in old versions of HPCC (2011) such function did not exist. But many releases have happened since then.

Upvotes: 2

Views: 150

Answers (1)

Oscar Foley
Oscar Foley

Reputation: 7025

I asked if official HPCC forums and there is NO native IsNumeric function in ECL.

In the answers there are several nice ECL workarounds better than mine. The best seems to be:

IsNumeric(STRING n) := n = (STRING)(DECIMAL)n;

Upvotes: 2

Related Questions