Postgres query to check a string is a number

前端 未结 6 1342

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

6条回答
  •  长情又很酷
    2020-12-01 18:31

    I fixed the regular expression that a_horse_with_no_name has suggested.

    SELECT '12.41212' ~ '^\d+(\.\d+)?$'; -- true
    SELECT 'Service' ~ '^\d+(\.\d+)?$'; -- false
    

提交回复
热议问题