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

Output multiple regex matches

DataBlendingFan
6 - Meteoroid

Hi All,

 

I am analyzing a log file which has the following form: 

 

"Text text text KEYWORD 123 Text Text Text KEYWORD 345 Text Text Text KEYWORD 678"

 

I would like to extract KEYWORD 123, KEYWORD 345, KEYWORD 678 and have every match in a separate column. There could be also more occurrences than only 1-3 - I need to output them all.  Have tried it with RegEx (KEYWORD) (.*) ) but RegEx is returning only the FIRST match and the remaining keywords in the input string are ignored. 

 

Do you have an idea?

 

Regards,

BlendingFan :)  

2 REPLIES 2
Claje
14 - Magnetar

To split to columns in one step, you will need to know the maximum number of occurrences of keyword.  If you don't know this, we can still make this work, but will need two tools.

 

First, I tweaked your regex slightly:

(KEYWORD\s[^\s]*)

This should do basically the same thing but is more restrictive so it shouldn't accidentally incorporate additional unintended characters.

 

Using this with the "Tokenize" option in the RegEx tool we can split out the data to a finite number of columns.  You could set this to a very large number so you always have data, although some columns will be NULL.

 

If you don't want to deal with NULL columns, you can Split to Rows and then use a Cross Tab tool to create the columns.  For this you may want to use a RecordID tool before RegEx so that you can get back to 1 line per each.

SteveWayne
7 - Meteor

Hey Blendingfan

use the regex tool to tokenise the pattern

set no of columns to maximum matches that you find in the data

example workflow and output attached

Steve

Labels