Regex: The ways I used regex in Alteryx Challenge 121

by Terrence Miller

Today I learned about regex. Before joining the Data School I had never heard of it before so it was my first time experiencing it.

What is Regex?: A regular expression (also called regex or regexp) is a way to describe a pattern. It is used to locate or validate specific strings or patterns of text in a sentence, document, or any other character input.

Here is the link for Alteryx Challenge 121 for you to follow along.

The first use for Regex came with identifying the rows that started with a number

As you can see the rows are formatted such that there is a row about the stadium and then the following rows are information about the stadium.

The regex I used to do this is : (^\d+)\.

This takes each row and checks if it starts with 1 or more numerical values and ends with a ".". Allowing me to extract each stadium and city.

My second use of regex in this challenge was to remove the numbers.

The regex I used to do this is : ([A-Z].+)

This takes any capitalized letters from A-Z followed by 1 or more of anything.

My third use of regex in this challenge was to separate the numbers from capacity.

The regex I used to do this is : (\d+,?\d+)

This takes 1 or more digits, potentially followed by a "," , followed by 1 or more digits.

My 4th use of regex was to extract the date each game was played on.

The regex I used to do this is : \((.+)\)

This essentially pulls out 1 or more of anything that is surrounded by parenthesis.

The last time I used regex to complete this challenge is to replace the year in the date.

After using the datetime tool to change the format of the dates in RegExOut1_2 all of the years were 1400. This needs to be replaced with 2018.

A simple use of regex to replace 1400 with 2018

That's it all the regex I used to complete this challenge. Goodluck completing the rest of it yourself.

Fri 29 Sep 2023

2 mins read

Thu 28 Sep 2023

Tue 26 Sep 2023