From: Karsten Hilbert <Karsten.Hilbert@gmx.net>
To: pgsql-general@lists.postgresql.org
Subject: Re: How to allow null as an option when using regexp_matches?
Date: Wed, 8 Dec 2021 13:09:54 +0100
Message-ID: <YbCgkqv/TTG04J0T@hermes.hilbert.loc> (raw)
In-Reply-To: <CA+i5JwYMPY1PwACzD4tLn0PdXuyRXBF9x+d38QfzJ1kMkRet5A@mail.gmail.com>
References: <CA+i5JwYMPY1PwACzD4tLn0PdXuyRXBF9x+d38QfzJ1kMkRet5A@mail.gmail.com>
Am Wed, Dec 08, 2021 at 12:07:13PM +0000 schrieb Shaozhong SHI:
> We can do this:
> select count(*) from regexp_matches('Great London', 'Great
> London|Information Centre|Department for Transport', 'g');
>
> Is it possible to allow null as an option? something like this
> select count(*) from regexp_matches('Great London', 'null|Great
> London|Information Centre|Department for Transport', 'g');
You seem to want to apply coalesce() judiciously.
Best,
Karsten
--
GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: Karsten.Hilbert@gmx.net
Subject: Re: How to allow null as an option when using regexp_matches?
In-Reply-To: <YbCgkqv/TTG04J0T@hermes.hilbert.loc>
References: <CA+i5JwYMPY1PwACzD4tLn0PdXuyRXBF9x+d38QfzJ1kMkRet5A@mail.gmail.com> <YbCgkqv/TTG04J0T@hermes.hilbert.loc>
* 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