Answer the question
In order to leave comments, you need to log in
Regular expressions (POSIX), how to convert a string to a float?
Good afternoon. There is Postgres, it has POSIX regular expressions.
The task is to convert any string to a floating point number. Possible input strings
$15,500 .22
15,400.22$
15400.22$
$15400.22
15 400.22$
$15 400.22
15.400.2222$
$15.400.22
$ 15,400
15,400 $
15.400 $
$ 15.400
regexp_replace('14 32,33р', '([\d\s\w]+)([,.]+)', E'\\1', 'g')
Answer the question
In order to leave comments, you need to log in
E - means that this is not just a string to be replaced with, but a regular expression in which there is a link to the first group (the first pair of parentheses) You
can solve it with regular expressions, but why if there is to_number .
Your delimiters are too diverse, it will be necessary to somehow reveal the meaning of the delimiter.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question