"Aaron Bono" <postgresql@aranya.com> writes:
> I thought by using the FOR '#' I could specify exactly what part of the
> expression I would get but it still grabs the first (...) of the pattern.
Hmm ... I think that this is a bug in similar_escape(): it ought to
transform parentheses in a SIMILAR pattern into non-capturing parentheses.
Until this is fixed, your best bet is to use the POSIX-regexp form of
substring(). You can't sneak non-capturing parens through
similar_escape, because it'll try to escape the ? ...
regards, tom lane