This site uses different types of cookies, including analytics and functional cookies (its own and from other sites). To change your cookie settings or find out more, click here. If you continue browsing our website, you accept these cookies.
I need help with extracting the first word after each pipe.
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
Go to Solution.
Go to Solution.
did you try:
Regex_Replace([Text to Parse],".*?\|(.*)\b.*",'$1')
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.
Regex_Replace([Text to Parse],".*?\|(.*?)\b.*",'$1')
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.
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")," |")," |",", ")