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

From: matshyeq <matshyeq(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Regex "embedded options" does only work on the whole pattern?
Date: 2016-01-05 11:32:20
Message-ID: CAONr5=tdQZbG14HpXdgmu_iMvb682xWpwHtn2wv_cgX+fBeRAQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Makes sense.
Thank you both for clarifications!
Was only wondering if this feature is there so I could elegantly do
equivalent of perl's (small 'a', anycase 'sd', small 'f'):

$,="\n";
my $testr='1asdf
2AsdF
3AsDF
4asDf
5aSDf
6aSdf
7ASdf
8Asdf';
my @res = $testr =~ /a(?i:sd)f/g;
print @res;
-----
asdf
asDf
aSDf
aSdf

Thank you,
Kind Regards
~Maciek

On 4 January 2016 at 03:58, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> matshyeq <matshyeq(at)gmail(dot)com> writes:
> > I can see postgresql claims to supports regular expression flags:
>
> Yup.
>
> > 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).
>
> Not all of them would make sense locally; in fact I'd venture that
> case-sensitivity is the *only* flag that anyone would consider using
> that way.
>
> > 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.
>
> Right. It says "begin with" and it means "begin with".
>
> We are not Perl and are not attempting to be bug-compatible with its regex
> engine. If you want bug-compatibility, see PL/Perl.
>
> regards, tom lane
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Michael Paquier 2016-01-05 12:15:30 Re: Streaming replication stacked.
Previous Message Steve Petrie, P.Eng. 2016-01-05 11:12:25 Re: Question -- Session Operations - Feasibility Of Proposed Synchronization Method?