Karsten Hilbert <Karsten.Hilbert@gmx.net> 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