| From: | Shaozhong SHI <shishaozhong(at)gmail(dot)com> |
|---|---|
| To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
| Cc: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: Can Postgres beat Oracle for regexp_count? |
| Date: | 2022-02-03 05:26:14 |
| Message-ID: | CA+i5JwZxxVy0uwg9bKYQOs=PZ617Xr7xTaPm4eqsrzsBz-BxNw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Hi, Tom, Lane,
On Wed, 2 Feb 2022 at 22:26, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> "David G. Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> writes:
> > Given we don't have a regexp_count function this isn't surprising...
>
> FYI, it's there in HEAD.
>
> In the meantime, you could possibly do something like
>
> =# select count(*) from regexp_matches('My High Street',
> '([A-Z][a-z]+[\s])', 'g');
> count
> -------
> 2
> (1 row)
>
> (Note that 2 is the correct answer given that there's no space
> after the third word; I trust Oracle agrees.)
>
> Can the whole 3 or 4 or 5 to be matched as 1?
>
The following has been attempted but no luck.
select regexp_matches('My High Street', '([A-Z][a-z]+[\s]*)+', 'g')
It is intended to match 'My High Street, but it turned out only 'Street'
was matched.
Regards, David
| From | Date | Subject | |
|---|---|---|---|
| Next Message | David G. Johnston | 2022-02-03 05:50:35 | Re: Can Postgres beat Oracle for regexp_count? |
| Previous Message | Abhishek Bhola | 2022-02-03 05:02:03 | Re: Subscription stuck at initialize state |