Re: Quick Regex Question
От | Howard Cole |
---|---|
Тема | Re: Quick Regex Question |
Дата | |
Msg-id | 476A5F80.30403@selestial.com обсуждение исходный текст |
Ответ на | Re: Quick Regex Question (Terry Fielder <terry@ashtonwoodshomes.com>) |
Ответы |
Re: Quick Regex Question
|
Список | pgsql-general |
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!
В списке pgsql-general по дате отправления: