Search Postgresql Archives

Re: regex help wanted

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

 



Karsten Hilbert <Karsten.Hilbert@xxxxxxx> writes:
> I would have thought "<[^<]+?:" should mean:

> 	match a "<"
> 	followed by 1-n characters as long as they are not "<"
> 	until the VERY NEXT ":"

> The "?" should make the "+" after "[^<]" non-greedy and thus
> stop at the first occurrence of ":", right ?  Or am I
> misunderstanding that part ?

No, non-greedy just means that if there are multiple ways to make the
pattern match the string, prefer the way that makes this sub-match the
shortest (whereas the default makes leftmost sub-matches longest).
If you don't want the char class to match : then you need to say that
explicitly.

BTW, I'm fairly sure that unless you are doing something that extracts
or replaces sub-matches, there is no value whatever in marking
quantifiers non-greedy; that just complicates life for the regex
compiler.  A match is a match, if you're not paying attention to
where the subpattern boundaries are.

			regards, tom lane


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general




[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