Search Postgresql Archives

Re: Quick Regex Question

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

 



Terry Fielder wrote:
Why do you need to? Check for the beginning of the string BEFORE the set brackets. The point of set brackets is "match from a set of chars". Since "beginning of string" can only match one place, it has no meaning as a member of a set. Or in other words, if it has meaning, it needs to be matched FIRST out of the set, and therefore you can just remove from the set and put before the set brackets.
or am I forced to use the (^| ) syntax?

Is it just me or are regular expressions crazy?
Complicated, not crazy.

Terry
Hmm. Still think they are crazy - sometimes the characters are interpreted as literals - other times not? Thats crazy in my book! It would make more sense to me if you had to escape the characters inside the [ ] as they seem to be everywhere else. There is possibly a good reason for this - But perhaps they are just crazy!!!
;)

I am trying to match the beginning of a name, so to search for
'how' in 'Howard Cole' should match
'col' in 'Howard Cole' should match
'ole' in 'Howard Cole' should NOT match,

So using ~* '(^| )col' works for me! As would '(^col| col)' etc.

Just as an aside, is there a function that escapes my search string so that any special regex characters are replaced? For example, if I was going to search for 'howard.cole' in the search string it would convert to 'howard[:.:]cole' or 'howard\.cole' - and then convert that into a postgres compatible string!





---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

              http://archives.postgresql.org/

[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