fildawg Posted October 31, 2006 Share Posted October 31, 2006 I'm very new to regex. I'm trying to parse out US dollars inclusive of commas, decimal point and dollar sign from a large (400 word) paragraph of text. Any advice to get me started would be greatly appreciated. Quote Link to comment Share on other sites More sharing options...
bljepp69 Posted November 1, 2006 Share Posted November 1, 2006 Try browsing this site - [url=http://regexlib.com/DisplayPatterns.aspx?cattabindex=2&categoryId=3]http://regexlib.com/DisplayPatterns.aspx?cattabindex=2&categoryId=3[/url] as they have a number of regular expressions already built, tested and commented. On the bottom of the page linked above, there is a regex that should do what you want:(?n:(^\$?(?!0,?\d)\d{1,3}(?=(?<1>,)|(?<1>))(\k<1>\d{3})*(\.\d\d)?)$)or, another one I found:^(\$)?((\d+)|(\d{1,3})(\,\d{3})*)(\.\d{2,})?$check the site to read the descriptions of what each does. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.