Alteryx Designer Desktop Discussions

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

Parse fields based on multiple keywords into multiple new fields

NeilFisk
9 - Comet

I have been attempting to parse a long string of text that a variety of keywords that may or may not be in the same order from row to row.  I first attempted to replace each keyword with a pipe and then use the text-to-columns tool to break them out into separate fields.  The issue with this is that I don't necessarily know which keyword the parse refers to.  I attempted also to throw in an equation to count the number of characters before the keyword to know which one it was (i.e., to know the order) but that got very messy.

 

I'm not great at REGEX but I believe this can be done easily using the RegEx tool.  Is there some way to do this with RegEx so that, knowing the keywords I want to parse on, that fields are created for each new keyword with the text that corresponds with it?

 

I have attached an example input and Desired Output (as two text inputs in a blank workflow).

 

Thanks!

10 REPLIES 10
apathetichell
18 - Pollux

@NeilFisk  Yes. It's possible with regex parse but the way | and options work under regex parse, I believe you would need 20+options under the parse tool to recreate the optionality provided by my macro.

 

Here's an example - let's say a field has issue: subject: comment: and the second row has comment:

 

to match both of these you'd need parse to say:

(.*)(issue: .*)\s{2}(subject:.*)\]s{2}(comment:.*)|(.*)(comment:.*) - and it kind of goes from there. - that would create four fields and match only those two cases. Anything not matching all three or not only comment would be null().

 

At it's best it would be the same as text to column/splitting based upon two spaces. or two spaces and a :... - and I'd personally prefer swapping \s{2} for something and going from there.

 

Labels