Andrew Gierth <andrew@tao11.riddles.org.uk> writes:
> I looked up the spec on this point. As far as I can see, we're not
> following it, but neither does the spec do what the OP wanted; in fact
> the result should have included the _leading_ Q as well as the trailing
> one.
Huh, interesting. So we should be translating the initial substring
to a non-greedy pattern. I believe Spencer's engine can handle that
by sticking (?:...){1,1}? around it.
Come to think of it, we probably need to be putting (?:...) around
the trailing substring as well. I suspect what we're doing today
produces non-spec results if "|" appears in the trailing part.
regards, tom lane