From the course: PostgreSQL: Advanced Queries
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Pattern matching with regular expressions - PostgreSQL Tutorial
From the course: PostgreSQL: Advanced Queries
Pattern matching with regular expressions
- [Instructor] If you need to locate text strings within the values stored in a database, then you could use a like operator. But a more powerful approach is to leverage regular expressions. Regular expressions provide a pattern-matching syntax that's used in a wide variety of programming languages. So like learning structured query language, taking the time to learn how regular expressions work will benefit you throughout your entire career in data science. I've opened the regular_expressions.txt file here, and we can see how to work with them in PostgreSQL. Regular expressions take a common prompt format. First, we have the input string that you want to search within, then a pattern matching operator, and, finally, the character sequence or the text that you want to find. The match operators all include the tilde character, and I have them listed out on lines 6 through 9. By itself, tilde will make a case-sensitive match to the character sequence. Adding an asterisk will make it…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
(Locked)
Output row numbers with query results2m 29s
-
(Locked)
Cast values to a different data type2m 15s
-
(Locked)
Move rows within a result with LEAD and LAG5m 47s
-
(Locked)
Use an IN function with a subquery4m 7s
-
(Locked)
Define WHERE criteria with a series4m 30s
-
(Locked)
Solution: Calculations across rows4m 19s
-
(Locked)
Pattern matching with regular expressions6m 57s
-
(Locked)
-