ALTERYX INSPIRE | Join us this May for for a multi-day virtual analytics + data science experience like no other! Register Now

Alteryx Designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.
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

MarqueeCrew
19 - Altair
19 - Altair

@twentytu ,

 

 did you try:

 

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

 

 cheers,

 

 mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and reboot. Order shall return.
Please Subscribe to my youTube channel.
apathetichell
13 - Pulsar

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
19 - Altair
19 - Altair

Let's try:

 

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

 

 cheers,

 

 mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and reboot. 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
13 - Pulsar

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