Currently using regex tool and the expression ([a-zA-Z\s']+=\s?\d+) to parse a string into an unknown amount of fields.
*shown below*
These are examples of how the string can be formatted;
- words - words - words….... - SquareFeet= 4, Chairs= 7, Rooms= 20, Due Date= 12/30/2023
- words - words - words….... - SquareFeet= 90, Chairs= 17, Rooms= 0, Due Date= 7/25/24
- words - words - words….... - SquareFeet= 42, Chairs= 15, Rooms= 10, Due Date= 04/19/24
*Had to manipulate the values due to privacy but there are a random amount of strings within the '-' symbols, before the string might have the fields called SquareFeet, Chairs, Rooms, and/or Due Date.*
Here is an example output with the current expression;
SquareFeet | Chairs | Rooms | Due Date |
4 | 7 | 20 | 12 |
90 | 17 | 0 | 7 |
42 | 15 | 10 | 04 |
It parses correctly except for the Due Date. It only pulls in the values before the '/' symbol. How can I edit my regex regular expression so that it pulls the entire date? That way my results look like below?
SquareFeet | Chairs | Rooms | Due Date |
4 | 7 | 20 | 12/30/2023 |
90 | 17 | 0 | 7/25/24 |
42 | 15 | 10 | 04/19/24 |
\d+ won't capture the slashes that you have in your dates, so could you do something like anything before a comma+space or nothing? or anything except for a comma+space?
This worked for me for example: ([a-zA-Z\s']+=\s?[^,]+)
I assume you need only the last 4 data items from each row.
And the strings before them might have "=" character which might confuse the RegEx function.
So I would first reverse the string to get the "first" 4 data items, and then reverse them back to the original order.
Here is a sample workflow.
I hope this helps.
Workflow
Output
If you want to keep the original order of columns, you may add Select tool.
It is also possible to order the columns automatically , but you need to add a coulpe of more steps.
Hi, @livluvlaf4lyf
1- If you don't care the order of fields, then follow the above flow part.
2- Else you can see the dynamic output and rename it.
(?:[[:alpha:]\s]+?\=\s?)([\d\/]+?)(?=,|$)