Understanding STRING_TO_ARRAY() in PostgreSQL

In PostgreSQL, string_to_array() is a string function that allows us to create an array from a string. It splits the string based on the specified delimiter and returns a text array as a result.

If we specify a null delimiter, then each character becomes an element in the array. If the delimiter string is empty, then the whole string becomes a single element in the array.

We also have the option of turning a specific substring into null if required.

Read more

A Brief Overview of SUBSTR() in PostgreSQL

In PostgreSQL, we can use the the substr() function to return a substring from a string, based on a starting point. We have the option of specifying how many characters to return.

We pass the string as the first argument and the start position as the second. If we want to specify how long the substring should be, we can pass a third argument that specifies how many characters to return.

The function returns the same result as the substring() function (which uses a slightly different syntax).

Read more

Understanding PostgreSQL’s REGEXP_INSTR() Function

In PostgreSQL, the regexp_instr() function returns the starting or ending position of the N‘th match of a POSIX regular expression pattern to a string. If there’s no match, it returns zero.

We pass the string and pattern as arguments. The function also accepts some optional arguments that allow us to be specific with how the function works.

Read more