Skip to content
Advertisement

REGEX Extract Amount Without Currency

I am trying to extract amounts from a string that will not have currency present. Any number that does not have decimals should not match. Commas should be allowed assuming they follow the correct rules (at hundreds marker)

I’m a noob to REGEX so I know my above statement already does not meet the criteria i’ve listed. However, i’m already stuck getting the error (INVALID_FUNCTION_ARGUMENT) premature end of char-class on my REGEX_EXTRACT line


Can someone point me in the right direction? How can I resolve my current issue? How can I modify to correctly incorporate the other criteria listed?

Advertisement

Answer

Here is a general regex pattern for a positive/negative number with two decimal places and optional thousands comma separators:

Demo

Your updated query:

From the Presto docs I read, it supposedly supports Java’s regex syntax. In the event that lookarounds are not working, you may try this version:

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement