Important Community update: The process for changing your account details was updated on June 25th. Learn how this impacts your Community experience and the actions we suggest you take to secure your account here.

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.

Regex String Parsing but dynamically pulling full date if it's there

livluvlaf4lyf
6 - Meteoroid

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*

457_508_1.25.png

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;

SquareFeetChairsRoomsDue Date
472012
901707
42151004

 

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?

SquareFeetChairsRoomsDue Date
472012/30/2023
901707/25/24
42151004/19/24
3 REPLIES 3
alexnajm
17 - Castor
17 - Castor

\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?[^,]+)

Yoshiro_Fujimori
15 - Aurora

@livluvlaf4lyf ,

 

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

1283453_Workflow.png

 

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.

1283453_Output.png

flying008
14 - Magnetar

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\/]+?)(?=,|$)

 

 

录制_2024_06_11_09_49_18_816.gif

Labels