pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedWhat is the regex for apostraphe in postgres?
4+ messages / 4 participants
[nested] [flat]
* What is the regex for apostraphe in postgres?
@ 2021-10-14 10:31 Shaozhong SHI <shishaozhong@gmail.com>
0 siblings, 1 reply; 4+ messages in thread
From: Shaozhong SHI @ 2021-10-14 10:31 UTC (permalink / raw)
To: pgsql-sql <pgsql-sql@lists.postgresql.org>
Can we check whether a text string contains apostraphe ' of not?
Regards,
David
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: What is the regex for apostraphe in postgres
@ 2021-10-14 12:31 David G. Johnston <david.g.johnston@gmail.com>
0 siblings, 0 replies; 4+ messages in thread
From: David G. Johnston @ 2021-10-14 12:31 UTC (permalink / raw)
To: Shaozhong SHI <shishaozhong@gmail.com>; +Cc: pgsql-sql <pgsql-sql@lists.postgresql.org>
On Thursday, October 14, 2021, Shaozhong SHI <shishaozhong@gmail.com> wrote:
> Can we check whether a text string contains apostraphe ' of not?
>
>
Yes. But if you write the regex using single quotes to denote the literal
you need to follow sql literal writing conventions for escaping the single
quote inside the literal. This is documented.
David J.
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: What is the regex for apostraphe in postgres?
@ 2021-10-14 12:35 Torsten Grust <teggy@fastmail.com>
parent: Shaozhong SHI <shishaozhong@gmail.com>
0 siblings, 1 reply; 4+ messages in thread
From: Torsten Grust @ 2021-10-14 12:35 UTC (permalink / raw)
To: Shaozhong SHI <shishaozhong@gmail.com>; pgsql-sql <pgsql-sql@lists.postgresql.org>
Hi David,
in a SQL string literal (or regular expression), an apostrophe is represented by '' (double apostrophe):
SELECT 'foo''bar' SIMILAR TO '_+''_+';
-> #t
Cheers,
—T
On Thu, Oct 14, 2021, at 12:31, Shaozhong SHI wrote:
> Can we check whether a text string contains apostraphe ' of not?
>
> Regards,
>
> David
--
| Torsten Grust
| teggy@fastmail.com
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: What is the regex for apostraphe in postgres?
@ 2021-10-14 15:19 Steve Midgley <science@misuse.org>
parent: Torsten Grust <teggy@fastmail.com>
0 siblings, 0 replies; 4+ messages in thread
From: Steve Midgley @ 2021-10-14 15:19 UTC (permalink / raw)
To: Torsten Grust <teggy@fastmail.com>; +Cc: Shaozhong SHI <shishaozhong@gmail.com>; pgsql-sql <pgsql-sql@lists.postgresql.org>
On Thu, Oct 14, 2021 at 5:35 AM Torsten Grust <teggy@fastmail.com> wrote:
> Hi David,
>
> in a SQL string literal (or regular expression), an apostrophe is
> represented by '' (double apostrophe):
>
> SELECT 'foo''bar' SIMILAR TO '_+''_+';
> -> #t
>
> Cheers,
> —T
>
> On Thu, Oct 14, 2021, at 12:31, Shaozhong SHI wrote:
>
> Can we check whether a text string contains apostraphe ' of not?
>
> Regards,
>
> David
>
>
>
I think it's helpful to clarify that "double apostrophe" means in this
context a single apostrophe twice (ie ' ' ), not the single character
"double apostrophe" (ie ")
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2021-10-14 15:19 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-10-14 10:31 What is the regex for apostraphe in postgres? Shaozhong SHI <shishaozhong@gmail.com>
2021-10-14 12:35 ` Torsten Grust <teggy@fastmail.com>
2021-10-14 15:19 ` Steve Midgley <science@misuse.org>
2021-10-14 12:31 Re: What is the regex for apostraphe in postgres David G. Johnston <david.g.johnston@gmail.com>
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