Saturday, April 15, 2006

Using regular expressions and SELECT (instead of LIKE) with PostgreSQL:

Category: "postgresql"
Topic:

Using regular expressions and SELECT with PostgreSQL

Some time ago I found this list of how Postgres supports regular expression searching, and case-insensitive searching in particular, and then I couldn't find it. If you're familiar with Unix and Perl regular expressions, these are very similar, so it's an easy pickup and very powerful. Just use these regular expressions with SELECT in your PostgreSQL queries instead of the LIKE operator, and you're ready to go. So before I lose my printout again, I thought I better include it's contents here.

Here's a the table of regular expression operators, re-typed from a URL I can't find anymore:

Comparison Operator
regular expression ~
regular expression, case-insensitive ~*
not equal to regular expression !~
not equal to regular expression, case-insensitive !~*

There is also a table of regular expression special characters, but I don't have the time to re-type those just now.

0 Comments:

Post a Comment

<< Home