RegEx Parse Comma Separated Numbers
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi,
I have a data set which as two different formats. I have attached a mock set. I am looking to parse out the third from last and last figures (as denoted by 2s in the mock data). So far, I have used the following regex "\w\s(\w{3})\s\w+\s+\w{3}\s+\d+", however, when I reach the first number, I am having issues as it can differ formats for example 0.05 to 1,234,567.89.
If someone could please assist with the simplest regex to parse both the third from last and last number, that would be greatly appreciated.
Thanks,
Daniel
Solved! Go to Solution.
- Labels:
- Regex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi @danielmaguire ,
This is a simple matter of replacing any instance of a double space (\s) with a delimiter (%), then simply text to columns on the delimiter:
M.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Thanks for the rapid replies @mceleavey and @HomesickSurfer .
@mceleavey I have tried using your solutions which should work great, but I just noticed on the actual data, I am getting a red 'NOT OK' in the final column. Do you know why this may be?
Thanks,
Daniel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I think the solutions provided probably work better for your specific problem - but if you want to continue in your regex learning I believe the parse syntax for
0.05 to 1,234,567.89 could be something like ([0-9\,]+\.*\d*) should work. any number of digits and commas - followed possibly by a period (or more unfortunately) followed by more numbers (possibly).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
HI @danielmaguire ,
I don't see your data, so I have no idea unfortunately.
I guess it is to do with being in a different format to the sample data.
Have a play with the number of columns etc.
M.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Perhaps using GetWord is your solution, assuming that your string data has consistent breaks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
