From the course: Data Science on Google Cloud Platform: Designing Data Warehouses

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Regular expressions

Regular expressions

From the course: Data Science on Google Cloud Platform: Designing Data Warehouses

Start my 1-month free trial

Regular expressions

- [Narrator] Regular expressions provide powerful search and replace capabilities. Incorporating them within SQL, can save a lot of code to achieve the same results. Google BigQuery supports regular expression capabilities that can be used for searching and replacing strings. We will use this capability to extract last name from the patient name, and then also replace the space in the name with an underscore. So here is the query. We use the REGEXP_EXTRACT function to extract the last name form the name column. Note how the regular expression is mentioned with the leading R, followed by the expression itself in double codes. We use REGEXP_REPLACE function to replace the space with an underscore. The regular expression itself is very simple, but the idea is to show you the capability available within BigQuery. Let's make sure that Legacy SQL is disabled before running this query. On executing this query, we see that the last name is extracted from the name, as well as the space…

Contents