Search Postgresql Archives

Re: Quick Regex Question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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?

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
      subscribe-nomail command to majordomo@xxxxxxxxxxxxxx so that your
      message can get through to the mailing list cleanly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux