Regex "embedded options" does only work on the whole pattern?

From: matshyeq <matshyeq(at)gmail(dot)com>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Regex "embedded options" does only work on the whole pattern?
Date: 2016-01-03 15:49:25
Message-ID: CAONr5=uz_LptdYG7R06p0EOmk_ygKutz1na+K-1Tt7ig2kXyKw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

I can see postgresql claims to supports regular expression flags:
http://www.postgresql.org/docs/current/static/functions-matching.html#POSIX-EMBEDDED-OPTIONS-TABLE
which I suppose aims to be the equivalent of perl's *(?adluimsx-imsx:pattern)
<http://perldoc.perl.org/perlre.html#(%3fadlupimsx-imsx)>*
Extended Patterns <http://perldoc.perl.org/perlre.html#(%3fadlupimsx-imsx)>.

What I find don't makes sense to me is that those flags could be used to
switch on/off match feature locally as opposed to the whole regex (same as
though flags parameters of regex functions).

Perl supports that locality while postgres documentation says:

"*An ARE can begin with embedded options: a sequence (?xyz) (where xyz is
one or more alphabetic characters) specifies options affecting the rest of
the RE. These options override any previously determined options — in
particular, they can override the case-sensitivity behavior implied by a
regex operator, or the flags parameter to a regex function.*
"

Does that mean these "EMBEDDED OPTIONS" can be only defined at the
beginning of the pattern and therefore don't offer anything extra over *flags
*option?
By the looks of the table it seems postgres supports locality ("*rest of RE*"
in description for b, e, q option)
I tried to switch case insensitieness with "(?i)" in the middle of the
pattern but I'm getting:
********** Error **********
ERROR: invalid regular expression: quantifier operand invalid
SQL state: 2201B

When I do "(?i)" at the beginning of the pattern it works but then applies
to the whole pattern.

Any ideas?

Thank you,
Kind Regards
~Msciwoj

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Marc Munro 2016-01-03 19:25:27 Re: How do I implement a .XSD in Postgres?
Previous Message chiru r 2016-01-03 11:46:25 Re: Happy New Year