Re: regex failing - Mailing list pgsql-general

From Steve Baldwin
Subject Re: regex failing
Date
Msg-id CAKE1AiYPrDhzn_yyhy0Sfdij2XgtpkCzG4CXuLAoSKAh3=aOKg@mail.gmail.com
Whole thread Raw
In response to regex failing  (Zahir Lalani <ZahirLalani@oliver.agency>)
List 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@oliver.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

 

pgsql-general by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: regex failing
Next
From: Sergey Fukanchik
Date:
Subject: Re: regex failing