In case you missed the announcement: Alteryx One is here, and so is the Spring Release! Learn more about these new and exciting releases here!

Alteryx Designer Desktop Discussions

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

Regex Line Extraction

DelData
9 - Comet

Hi there,

 

Can you help...I am trying to use RegEx in Alteryx useing key words to identify data i need to extract from a column.

 

The picture below shows what i want......I want to.....

 

  1. Extract the Delivery Mode in Column B to produce Column C
  2. Extract the Category in Column B to produce Column D

...I have used things like reg101 and it does look to work online but when i try regex in Alteryx column C extracts the Delivery Mode but also includes all text after delivery mode which i do not want.

 

...Column D is a more complicated since Category has additional line spaces and I only want the line after its ")"

 

Can anyone help me on this....attached workflow to update 😀

 

Line Extraction Wanted.png

7 REPLIES 7
Luke_C
17 - Castor
17 - Castor

Hi @DelData 

 

Give these a shot:

 

Delivery Mode:

REGEX_Replace([Data], ".*Delivery Mode\s+([^\r\n]+).*", "$1")

 

  • .* → Matches everything before "Delivery Mode".

  • Delivery Mode\s+ → Finds "Delivery Mode" followed by one or more spaces.

  • ([^\r\n]+) → Captures everything on that same line (i.e., the delivery mode, like "Standard Class").

  • .* → Matches everything after the captured value (but doesn't include it in the result).

  • "$1" → Returns only the captured part (i.e., "Standard Class").

Category:

REGEX_Replace([Data], ".*Category\s*\(.*\)\s*([^\r\n]+).*", "$1")

 

 

  • .*Category\s* → Looks for "Category" and allows optional spaces after it.

  • \(.*\) → Matches everything inside the parentheses (we don’t need this part).

  • \s*([^\r\n]+) → Captures everything after the parentheses (i.e., the category name, like "Best in Class").

  • .* → Matches everything after the captured value (but doesn't include it in the result).

  • "$1" → Returns only the captured part (i.e., "Best in Class").

 

 

image.png

Pilsner
11 - Bolide

Hello @DelData 

I have used the following two regex statements to extract the information you're after.


Delivery Mode: 'Delivery Mode (.*?)\n' This looks for everything after the words delivery mode, before the next new line.
Category: 'Category \(.*?\)\s(.*?)\n' This looks for the word 'Category', then finds the set of brackets, and extracts the text, after the')' bracket, before a new line.

Screenshot 2025-04-03 133036.png


As I used two separate regex tools (both set with the parse output method) I had to join the data back together. 

I have attached the workflow I used below. Please let me know if you have any questions.

Regards - Pilsner

DelData
9 - Comet

Perfect....this works exactly as i wanted......I need to practice RegEX more.......thank yuu for taking time out to help 👍

DelData
9 - Comet

Perfect....another great solutions and works exactly as i wanted......I need to practice RegEX more.......thank you for taking time out to help 👍

Luke_C
17 - Castor
17 - Castor

Great to hear! Regex looks like an alien language at first, but definitely an invaluable skill to invest time to learning. 

OllieClarke
15 - Aurora
15 - Aurora

Hi @DelData 

 

I see you've already got some answers, but if you want a one tool/function solution then this RegEx in parse mode should do it:

Delivery Mode (.+?)\n.*\) (.+?)\n

this will capture whatever is on the line after Delivery Mode, and then whatever follows the final closing bracket (on the same line)

image.png

Hope that helps,

 

Ollie

DelData
9 - Comet

Thanks Ollie......this is another great example.....i can see benefits of knowing more on RegEx 😀

Labels
Top Solution Authors