PostgreSQL, an open-source relational database system, provides several string manipulation functions, including the SUBSTRING function. The SUBSTRING function is used to extract a part of a string based on a specified starting position and, optionally, the length. This guide covers the syntax and various examples of using the SUBSTRING function, including using regular expressions and extracting data from table columns. Additional features and scenarios for using the function, such as sorting data and handling email addresses, are also explored.
Table of contents
Environment detailsPostgreSQL substring functionExtract matching Substrings with SQL Regular ExpressionUse a Negative number as starting position in the SUBSTRING functionConclusionSee moreSort: