I'm trying to extract dollar amounts from strings. The strings may be unicode and not ascii. I haven't/can't review them all.
I want the numbers following the $ only.
This code doesnt work, but is close I think.
The solution should be:
Thanks in advance.
Related, if I want to practice regex here: https://regex101.com/ do you know what "Flavor" (left tab) Stata uses/is?
Code:
clear input str60 phrase "the $30.0 million shares" "if $999,999 dollars are" "can add $45 billion" "greater than $3.02 per share" "the 75 free turkeys " end
This code doesnt work, but is close I think.
Code:
gen amount = "" replace amount = regexs(1) if regexm(phrase, "\$(\d{1,3}(?:,\d{3})*(?:\.\d+)?)")
Code:
clear input float amount 30.0 999999 45 3.02 . end
Related, if I want to practice regex here: https://regex101.com/ do you know what "Flavor" (left tab) Stata uses/is?
Comment