Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id E70C99FB713 for ; Wed, 21 Mar 2007 17:32:40 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-new, port 10024) with ESMTP id 37861-07 for ; Wed, 21 Mar 2007 17:32:25 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from bach.incentre.net (bach.incentre.net [198.161.96.4]) by postgresql.org (Postfix) with ESMTP id 411239FB62D for ; Wed, 21 Mar 2007 17:32:28 -0300 (ADT) Received: from sigurd.incentre.net (sigurd.incentre.net [206.75.213.195]) by bach.incentre.net (8.12.9p2/8.12.9) with ESMTP id l2LKWQnV050572 for ; Wed, 21 Mar 2007 14:32:27 -0600 (MDT) (envelope-from guy@incentre.net) Subject: Re: Regular Expressions From: Guy Fraser To: pgsql-sql@postgresql.org In-Reply-To: <46016D43.9030300@fastcon.com.br> References: <46013B89.4040603@fastcon.com.br> <1174487806.26600.15.camel@sigurd.incentre.net> <46016D43.9030300@fastcon.com.br> Content-Type: text/plain Organization: The Internet Centre Date: Wed, 21 Mar 2007 14:32:26 -0600 Message-Id: <1174509146.26600.39.camel@sigurd.incentre.net> Mime-Version: 1.0 X-Mailer: Evolution 2.6.3 (2.6.3-1.fc5.5) Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200703/290 X-Sequence-Number: 27928 On Wed, 2007-03-21 at 14:37 -0300, Ezequias R. da Rocha wrote: > Guy Fraser escreveu: > > On Wed, 2007-03-21 at 11:04 -0300, Ezequias R. da Rocha wrote: > > > >> Hi list, > >> > >> I would like to know if postgresql has a Regular Expressions (Regex) > >> implemented already. > >> > >> With it we could implement queries like > >> > >> Select * from myClientes where name = 'E[zs]equias' > >> > >> > > Case Sensitive Regular Match ~ > > Case Insensitive Regular Match ~* > > Negated Case Sensitive Regular Match !~ > > Negated Case Insensitive Regular Match !~* > > > > Select * from myClientes where name ~ 'E[zs]equias' > > > > > >> where the result occurs even if the field has Ezequias or Esequias. > >> > >> Regards > >> Ezequias > >> > >> ---------------------------(end of broadcast)--------------------------- > >> TIP 2: Don't 'kill -9' the postmaster > >> > >> > Great I am thinking of putting my like to rest. I felt it faster than > "like" statement, have you any information about that ? > No I don't know if regular expressions are faster than "LIKE" but I think they are more flexible. When developing queries, I usually try different methods of matching to find out what works best for each circumstance. Some times upper() lower() and substr() with an "=" are more effective than other methods. One of the more powerful features of PostgreSQL is the ability to use sub-selects to reduce the time required to process a subset of data from a larger volume of data. Example : select * from ( select ss_time, ss_date, ss_type, ss_data from full_set where ss_type in ('type_a','type_x') ) as sub_set where upper(ss_data) ~ '[A-Z][0-9][A-Z] ?[0-9][A-Z][0-9]' order by ss_time, ss_date, ss_type ; > Ezequias > > ---------------------------(end of broadcast)--------------------------- > TIP 7: You can help support the PostgreSQL project by donating at > > http://www.postgresql.org/about/donate >