Re: Quick Regex Question - Mailing list pgsql-general

From Howard Cole
Subject Re: Quick Regex Question
Date
Msg-id 476A4598.50907@selestial.com
Whole thread Raw
In response to Re: Quick Regex Question  (Richard Huxton <dev@archonet.com>)
Responses Re: Quick Regex Question
List 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?

pgsql-general by date:

Previous
From: Martijn van Oosterhout
Date:
Subject: Re: INDEX on a composite type
Next
From: "A. Kretschmer"
Date:
Subject: Re: Quick Regex Question