In this blog, we will focus on learning the various Output Methods for the Alteryx Regex Tool, and some examples. This tutorial follows up from my previous post, so I would recommend going there to learn the syntax first. To first introduce them, there are four possible choices for your Output Method: Replace, Tokenize, Parse, and Match. You can find these here:
Alteryx Regex output methods

if you haven’t got it from the previous post, the dataset I’m using can be found here: Regex Example

Alteryx Regex Tool: Replace

We’ll start from the top with the replace tool. This method does exactly what you think it would, it finds any match of your given expression and replaces it with your specified replacement text. This can be used for a lot of very nice data filtering, especially since you can leave the replacement text blank to simply remove the unwanted text. Other than that, you can chose to replace with columns from your expression, the entire text you found. This also has the option to remove anything that wasn’t found. Finally, you also have the option of anything else you manually type in yourself.

Replace Examples

These are three examples of how the replace tool can be used and I would recommend you try these yourself to get a look at the output yourself.

This will replace all occurrences of a ‘-‘ with a ‘,’ and also the rest of the text. Clicking the checkbox will result in only the replacement text.

This will find all digits followed by a while space character and replace them with nothing, essentially removing them. Finally:

This will find the same text as before but will instead only return the digits and white space that was found.

Alteryx Regex Tool: Match

The match tool works very similar to the replace tool, but it will instead return if the entire record matching your expression. This means, as well, that partial matches will still return false. An extra column is made for the boolean result of your match query.

Match Examples

This example will return false for all records as, even though all records contains numbers, it isn’t the entirety of their contents.

This example will return true, since looking for all characters will match the entire contents of the record.

Alteryx Regex Tool: Parse

The parse tool allows you to separate a column by choosing which of your data will contribute to the output. This can be done with the use of brackets ‘()’ to indicate a selection/column. Each grouping of your data will automatically be assigned a new column, while anything left (including parts of your expression outside brackets), will be left behind. An important note as well, if multiple occurrences of the same expression are found, the right-most will be used.

Parse Examples

This example displayed that point exactly. There are a number of times where there are characters surrounding an ‘e’ for most of the records. You can see a number of different examples of how the right-most takes priority in all cases.

This examples done on the ‘Name’ column shows how this can be used to get the peoples’ first and last name from each record.

Alteryx Regex Tool: Tokenize

The tokenize tool is kind of similar to the text to column tool, allowing you to separate a column based on what you want in the columns. Alternatively, you can use the notation of [^] (not in set) to exclude a value that you don’t want in the columns, acting as a deliminator. If you want to, as well, you can chose to have the output to be to rows instead of columns.

Tokenize Examples

This example will separate columns based on having 1 or more – in between them. In essence, we are looking for anything that is not a dash and using that as our column, separating when we do find a -, in this case.

This example is very similar except the deliminator is a comma.

Conclusion

I hope these two blogs helped anyone who is trying to learn the Regex Tool. If you would like to check out any of my other blogs feel free too check out my page.

Darby Lehane
Author: Darby Lehane