Hi,
I need help with extracting the first word after each pipe.
For example:
Text to Parse | Result I need |
djoa|if hoa.eeanho | if |
jfie|no jfieoa |ad_d jfieoa fjeoafje hfeau | no, 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
Solved! Go to Solution.
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.
Let's try:
Regex_Replace([Text to Parse],".*?\|(.*?)\b.*",'$1')
cheers,
mark
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.
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
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")," |")," |",", ")