"Daniel Verite" <daniel@manitou-mail.org> writes:
> Robert Schreiber wrote:
>> What appears to be happening is that the _Q? on the tail_ is being
>> matched, but _the Q is also being included in the collected data.__
> You seem to expect that % must be non-greedy and let the final Q?
> match 1 Q instead of 0, but there doesn't appear to be anything
> in the doc that supports this interpretation.
> In fact, it mentions that "%" is comparable to ".*" in POSIX
> regular expressions, and the latter _is_ greedy.
Right. You could get the behavior you want using a non-greedy quantifier,
but you'd have to use the POSIX regexp functions, not substring().
regards, tom lane