pg.ddx.io pgsql-hackers@postgresql.org mailing list archive
help / color / mirror / Atom feed From: Chapman Flack <chap@anastigmatix.net>
To: Tom Lane <tgl@sss.pgh.pa.us>
To: Joel Jacobson <joel@compiler.org>
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: Some regular-expression performance hacking
Date: Sat, 20 Feb 2021 18:31:39 -0500
Message-ID: <60319BDB.2040302@anastigmatix.net> (raw )
In-Reply-To: <3028106.1613748380@sss.pgh.pa.us >
References: <1340281.1613018383@sss.pgh.pa.us >
<85140bfb-516c-449b-8a03-7930abb42b88@www.fastmail.com >
<1813969.1613250697@sss.pgh.pa.us >
<913516b8-c3d7-4dea-bf60-d735cf4673f1@www.fastmail.com >
<2155152.1613358697@sss.pgh.pa.us >
<99f6cbe0-6e58-4e41-add0-977271a5cf84@www.fastmail.com >
<2752386.1613595636@sss.pgh.pa.us >
<5deabab3-a335-4b57-a046-8a9ad8f2f142@www.fastmail.com >
<12e6381c-adc1-4711-a619-864fb8df969c@www.fastmail.com >
<2840118.1613671847@sss.pgh.pa.us >
<2845172.1613674385@sss.pgh.pa.us >
<b16bccc0-3f98-47ad-81aa-699a3e00630d@www.fastmail.com >
<3028106.1613748380@sss.pgh.pa.us >
On 02/19/21 10:26, Tom Lane wrote:
>> "foo\nbar".match(/([\w\W]+)/)[1];
>> "foo
>> bar"
>
> 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.
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?
We currently give 2201B: invalid regular expression: invalid embedded option
on an attempt to use the syntax, so implementing it couldn't break anything
someone is already doing.
Regards,
-Chap
view thread (38+ messages) latest in thread
Message-ID: <60319BDB.2040302@anastigmatix.net>
Permalink: ../60319BDB.2040302@anastigmatix.net/
Also on: postgresql.org/message-id/60319BDB.2040302@anastigmatix.net
copy link · copy postgr.es
reply Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: chap@anastigmatix.net, tgl@sss.pgh.pa.us, joel@compiler.org, pgsql-hackers@lists.postgresql.org
Subject: Re: Some regular-expression performance hacking
In-Reply-To: <60319BDB.2040302@anastigmatix.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox