Re: Quick Regex Question

From: Howard Cole <howardnews(at)selestial(dot)com>
To: 'PgSql General' <pgsql-general(at)postgresql(dot)org>
Subject: Re: Quick Regex Question
Date: 2007-12-20 10:36:08
Message-ID: 476A4598.50907@selestial.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Richard Huxton wrote:
> 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)'
>
Your expression works fine Richard, as does '(^| )ho', but can you tell
me why '[ ^]ho' doesn't work?

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Martijn van Oosterhout 2007-12-20 10:38:42 Re: INDEX on a composite type
Previous Message Howard Cole 2007-12-20 10:25:50 Re: Quick Regex Question