Can anyone tell me the query to check whether a string is a number(double precision). It should return true if the string is number. else it should return false.
con
If you want to check with exponential , +/- . then the best expression is :
^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$
resulting in:
select '12.41212e-5' ~ '^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$' ;
as true.
The expression is from: https://www.regular-expressions.info/floatingpoint.html
You can check for other types of numbers, for example if you expect decimal, with a sign.
select '-12.1254' ~ '^[-+]?[0-9]*\.?[0-9]+$';