Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Discussions

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

Extract text of dynamic length

JohnO
7 - Meteor

I can't figure this one out. I need to extract a sentence from a wall of text:

 

You are receiving this message because you have chosen to be notified of failures. The following have failed to post since the last e-mail you received:

Shipment Client Keys: 00000000000000012345, 0000000123, 1234567890123.
Post failed with a message: xxxxxxxxxxxxxxxx.

This message was sent with high importance

 

I need to extract just the "Shipment Client Keys" sentence. The issue is that the ID numbers that follow vary widely in length.

 

Any help is greatly appreciated!

7 REPLIES 7
DataNath
17 - Castor

@JohnO the following will take ‘Shipment Client Keys’ and then all of the numbers until it reaches the end of the sentence (full stop). Let us know if the requirement is different of course:

 

Using the RegEx tool in Parse mode:

 

(Shipment Client Keys:.+)\.

DataNath
17 - Castor

Apologies, that won’t actually work as it’ll continue to the end of the whole sentence, I was testing with a break line in place accidentally. Try the following instead:

 

(Shipment Client Keys:[\d\s,]+)\.

JohnO
7 - Meteor

Thanks @DataNath! This is working.

 

Follow up question:  Some of the emails have more than one "Shipment Client Keys" line. Is there a way to capture all of them?

DataNath
17 - Castor

@JohnO does the number of times this can appear vary, or is it always a sets amount (say once or twice)? The RegEx tool also has a tokenize option whereby it’ll pull out all instances of a pattern, as opposed to just the first occurrence like parse mode does. You can either split out to columns when tokenising, or rows (which is usually the best option if the number can vary).

JohnO
7 - Meteor

Thanks, again @DataNath! Hopefully this is the last follow-up.

 

I have two types of entries that are failing:

 

Shipment Client Keys: 34716, 3PUSABQ01, 20220927.

and 

Shipment Client Keys: 861767, A3Y1, 09/13/2022.

 

Any suggestions?

DataNath
17 - Castor

Ah sorry @JohnO, I thought the IDs and parts to be captured were just numbers! This should capture anything up until the first full stop:

 

(Shipment Client Keys:[^.]+)\.

JohnO
7 - Meteor

No apology necessary. I thought the same thing until I saw the errors.

 

Many thanks @DataNath 

Labels