Get startedGet started for free

Writing regular expressions

Your marketing director needs to see how some campaigns and ad groups are performing. The performance of the campaigns and ad groups will determine the strategy for the upcoming quarter, so it is very important that the filtering is correct. Regular expressions are a great way to filter the campaigns and ad groups. Here are some examples to help you out:

  • You can use square brackets [] to match one of a set of characters. For example, if you wanted to match words beginning with a lower-case a or a lower-case b, you could use the pattern ^[a|b].*. The ^ character marks the beginning of a word, and the .* matches any characters that follow an a or a b.
  • You can define the end of a string by using the anchor $. For example, .*ly$ would match Finally and Gladly.
  • If you want to check for one of two regular expression components, you can use the pipe operator |. For example, Steve|Sarah would match Steve or Sarah.

The requests are simple. The first performance group the marketing director would like to see should contain the performance metrics for all Python and Python related campaigns, such as pandas. The second performance group is to understand how the branded campaigns are performing. The last performance group is a special interest case, where the marketing director would like to see how the Mugs and Sweaters ad groups are performing.

This exercise is part of the course

Marketing Analytics in Google Sheets

View Course

Exercise instructions

Use the examples above to help you write the following regular expressions. Note: after entering your formula, make sure to select another cell or press 'Enter' to allow the grader to evaluate your pattern.

  • Write a regular expression in cell H3 that will include all of the campaigns that begin with the character p or P (i.e. both upper-case and lower-case).
  • In cell H4, write a regular expression that will include any campaign that ends with the letter d.
  • For cell H5, write a regular expression that will select ad groups Mugs and Sweaters.

Hands-on interactive exercise

Turn theory into action with one of our interactive exercises

Start Exercise