Re: regex failing

From: Steve Baldwin <steve(dot)baldwin(at)gmail(dot)com>
To: Zahir Lalani <ZahirLalani(at)oliver(dot)agency>
Cc: "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: regex failing
Date: 2023-06-27 19:17:30
Message-ID: CAKE1AiYPrDhzn_yyhy0Sfdij2XgtpkCzG4CXuLAoSKAh3=aOKg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Probably not much help but it seems to work ok for me (unless I'm doing
something stupid). You didn't actually say how/where you were doing the
regex match, but the '~' operator seems to work ok.

[~/git/caas-sqs-consumer] psql
psql (15.3 (Homebrew), server 13.7)
SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384,
compression: off)
Type "help" for help.

bcaas=> select '1234:56' ~ '^([0-9]+[.]?[0-9]*)$';
?column?
----------
f
(1 row)

bcaas=> select '1234.56' ~ '^([0-9]+[.]?[0-9]*)$';
?column?
----------
t
(1 row)

On Wed, Jun 28, 2023 at 4:59 AM Zahir Lalani <ZahirLalani(at)oliver(dot)agency>
wrote:

> Hi All
>
>
>
> Got a weird one. I am using the regex below to case match numeric only
> values.
>
>
>
> '^([0-9]+[.]?[0-9]*)$'
>
>
>
> This works well by and large but not for a value like “1234:567”. This
> seems to match positive and then fails due to not being an actual number in
> the subsequent cast.
>
>
>
> Any ideas? (PG13)
>
>
>
> Z
>
>
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Sergey Fukanchik 2023-06-27 20:22:17 Re: regex failing
Previous Message David G. Johnston 2023-06-27 19:15:38 Re: regex failing