Re: Some regular-expression performance hacking

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Chapman Flack <chap(at)anastigmatix(dot)net>
Cc: Joel Jacobson <joel(at)compiler(dot)org>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Some regular-expression performance hacking
Date: 2021-02-21 01:13:29
Message-ID: 3374539.1613870009@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Chapman Flack <chap(at)anastigmatix(dot)net> writes:
> On 02/19/21 10:26, Tom Lane wrote:
>> Oooh, that's very interesting. I guess the advantage of that over using
>> the 's' flag is that you can have different behaviors at different places
>> in the same regex.

> Perl, Python, and Java (at least) all have a common syntax for changing
> flags locally in a non-capturing group, so you could just match (?s:.)
> -- which I guess isn't any shorter than [\w\W] but makes the intent more
> clear.

Hmm, interesting.

> I see that JavaScript, for some reason, does not advertise that. We don't
> either; we have (?:groups) without flags, and we have (?flags) but only
> global at the start of the regex. Would it be worthwhile to jump on the
> bandwagon and support local flags in groups?

Yeah, perhaps. Not sure whether there are any built-in assumptions about
these flags holding still throughout the regex; that'd require some
review. But it seems like it could be a useful feature, and I don't
see any argument why we shouldn't have it.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2021-02-21 02:04:16 Re: [PATCH] Present all committed transaction to the output plugin
Previous Message Chapman Flack 2021-02-20 23:31:39 Re: Some regular-expression performance hacking