Using regex in redshift to find dollar values
I have a field in a Redshift table that has user-generated text. The field is where users can say how much they think something costs.
Ideally it'd just be a decimal, but it's varchar. So users can type "I think this is worth \$25", or "I'd pay 55" or "\$117".
So I'm trying to use regexp_substr to pull this out. Specifically regexp_substr(f.comment_text, '\\$?[0-9]*'). But this doesn't work on a subset of entries for some reasons (eg Could do for $115).
If I remove the ? it works on that, but no longer on entries that don't use $. Why? And what should I use instead?
Category Data Science