Alteryx Designer Desktop Knowledge Base

Definitive answers from Designer Desktop experts.

RegEx Examples - 12 Handy Use Cases

AndrewL
Alteryx
Alteryx
Created

If you're like me, you may find RegEx a bit intimidating. While it can be confusing, once you get a handle on it you'll see just how powerful it actually is. Below is a post from the Discussion boards that should make an introduction into RegEx less daunting. The full post is below, and I've attached the sample workflow to this post as well.

 

A lot of data prep questions I get asked about seem to come back to the same answer - "Use Regex!"

 

However, RegEx isn't exactly easy to understand for someone who has never come across it before.

 

This is how I started out, but by dissecting other peoples' uses of RegEx, I started to understand how RegEx works and now I seem to use it in pretty much every workflow I create (slight exaggeration).

 

So I decided to upload the attached workflow that has 12 use cases for RegEx for you to use, adapt, learn from and improve on. Please download the attached Alteryx workflow and explore what's going on and you'll soon be more than comfortable with RegEx too!

 

I've also put some useful RegEx links on the original blog for this workflow here:http://www.theinformationlab.co.uk/2016/10/27/regex-practice-using-alteryx/

 

Feel free to upload your use cases for RegEx on this discussion post, along with examples, and perhaps we can start to create a small repository for everyone - from RegEx newbies to those highly skilled in this complex but extremely useful tool.

 

The attached workflow is in v10.5. Refer to our RegEx Tool Mastery if you'd like to learn more about the tool and its many uses!

 

Attachments
Comments
ulrich_schumann
8 - Asteroid
@AndrewL: the attached file just opens as a XML, not as a workflow. Could you please double-check. Thanks.
TaraM
Alteryx Alumni (Retired)

@ulrich_schumann - I just tested and the file opened in Alteryx for me. Make sure the *.yxmd file extension is set to open in Alteryx as the default association.

DataRangler
8 - Asteroid

This link to "The Regex Coach" provides a very useful tool for validating and building regex expressions, been using it for years. /https://the-regex-coach.en.softonic.com/ 

 

Built a regex email validation macro using Wikipedia definition of valid emails, if anyone is interested. 

 

REGEX_Match( [__LOCALPART__],"^[A-Za-z0-9! #$%&'*+=?^_`{|}~-]+(?:.[A-Za-z0-9!#$%&'*+=?^_`{|}~-]+)*$")