A Quick Look at PostgreSQL’s REGEXP_LIKE() Function

In PostgreSQL, we can use the regexp_like() function to check whether or not a match of a POSIX regular expression occurs within a given string.

We pass the string as the first argument and the pattern as the second argument. We can also provide a flag as an optional third argument, which determines how the function behaves.

Continue reading

Fix “function array_shuffle(integer) does not exist” in PostgreSQL

If you’re getting an error that reads “function array_shuffle(integer) does not exist” when using the array_shuffle() function in PostgreSQL, it’s probably because the argument you’re passing to the function is not an array.

More specifically, this error message implies that you’re passing an integer. The same error can occur when passing other non-array types (such as numeric), but the solution is the same.

The argument for this function must be an array.

To fix this error, replace the integer value with an array value when calling the array_shuffle() function.

Continue reading

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.

Continue reading

A Quick Look at PostgreSQL’s REGEXP_COUNT() Function

In PostgreSQL, the regexp_count() function returns the number of times a given POSIX regular expression pattern matches in a given string.

We pass the string and pattern as arguments. We can also pass an argument to specify where to start the search. Additionally, we also have the option of specifying a flag that changes the function’s behaviour.

Continue reading