Alteryx Designer Desktop Discussions

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

Extract The First Word after Character

twentytu
5 - Atom

Hi,

 

I need help with extracting the first word after each pipe. 

For example:

Text to ParseResult I need
djoa|if hoa.eeanhoif
jfie|no jfieoa |ad_d jfieoa fjeoafje hfeauno, add
oehaoe|yes jfo_dantoeha yes

 

Words are separated by space, but they contain other special characters, like . and _ 

 

I've researched for hours online, but couldn't find a way to get the result I want. I'm trying to use Regex, but can't really put them together.. please help

 

Alteryx Designer 2019.4 X64

 

Thank you!

 

Doris

6 REPLIES 6
MarqueeCrew
20 - Arcturus
20 - Arcturus

@twentytu ,

 

 did you try:

 

Regex_Replace([Text to Parse],".*?\|(.*)\b.*",'$1')

 

 cheers,

 

 mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
apathetichell
18 - Pollux

Not quite perfect - but drag a regex tool.

set to replace.

 

IMPORTANT - click on the box that says "copy unmatched text to output" - this need to be unchecked.

 

(\|)(\w+) in formula

 

$2| in output. Or $2,

 

Also - tokenize:

\|(\w+) - will work but your words will end up in different columns and you'll have to concatenate later.

MarqueeCrew
20 - Arcturus
20 - Arcturus

Let's try:

 

Regex_Replace([Text to Parse],".*?\|(.*?)\b.*",'$1')

 

 cheers,

 

 mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
twentytu
5 - Atom

Hi Mark,

 

Thank you for your quick reply!

 

I just tried your regex, but it returns everything after pipe "|".  I only need the first word after pipe and if there are several pipes in one column, I need the first word after each pipe. 

betodiwan
6 - Meteoroid

Hello, 

you can try to use the tool " text to column" using the pipe as a delimiter and after you get the first word of each column created 

apathetichell
18 - Pollux

replace(regex_replace([Text to Parse],".*?(\|\w+\s)?.*?","$1"),"|","")

 

FOR THE WIN.

 

And to finish the formatting:

REPLACE(TRIM(regex_replace([Text to Parse],".*?(\|\w+\s)?.*?","$1")," |")," |",", ")

Labels