Re: Quick Regex Question

From: Richard Huxton <dev(at)archonet(dot)com>
To: Howard Cole <howardnews(at)selestial(dot)com>
Cc: 'PgSql General' <pgsql-general(at)postgresql(dot)org>
Subject: Re: Quick Regex Question
Date: 2007-12-20 10:11:01
Message-ID: 476A3FB5.5040608@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Howard Cole wrote:
> Hi all,
>
> I don't understand the last result:
>
> select 'Ho Ho Ho' ~* '^Ho'; returns true
> select 'Ho Ho Ho' ~* ' Ho'; returns true
> select 'Ho Ho Ho' ~* '[^ ]Ho'; returns false (Please note there is a
> space between ^ and ])
>
> From my limited experience of regex, the last one is searching for either
> 'Ho' preceeeded by space or
> 'Ho' at the beginning of a string.

No, it's searching for not-space, the ^ inverts the meaning of the
square brackets. You probably want something like '(^Ho)|( Ho)'

--
Richard Huxton
Archonet Ltd

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ivan Sergio Borgonovo 2007-12-20 10:25:43 Re: Quick Regex Question
Previous Message Florian Aumeier 2007-12-20 10:10:08 Re: Quick Regex Question