Chapter 31. Using Regular Expressions
Data can be complicated; it’s not all just adding values together or counting things. For example, string data fields can have a lot of complexity, but using them is often essential in forming your data sets and analysis. Regular expressions (or regexes) are a set of commands that make parsing difficult strings much more achievable. In this chapter, we will cover what regexes are exactly, how they can be used in Prep Builder, and how to use some common regex functions.
What Are Regular Expressions?
Regular expressions are calculations that search for a pattern of characters (e.g., the value population) in a string of characters (e.g., "The population of the United Kingdom is 66,650,000 people"). Regexes are much more flexible in the patterns they can identify compared to the other string functions we’ve seen like LEFT(), MID(), and RIGHT().
One advantage of learning regexes is that they share a common set of commands across most data tools and therefore are highly transferable between data preparation tools. Another is how they can help you avoid building very complex string calculations using the simple string functions this book has covered thus far.
How to Use Regexes in Prep
There are three main ways to use regexes in Prep (Figure 31-1).
Figure 31-1. Regex functions available in Prep
To help you understand how to make use of regexes ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access