Regexp confusion - Mailing list pgsql-general

From Doug Gorley
Subject Regexp confusion
Date
Msg-id 4ACFACEE.8050001@gmail.com
Whole thread Raw
Responses Re: Regexp confusion
List pgsql-general
Trying to match some numbers, and I'm having some regexp problems.  I've
boiled it down to the following:

/* (1) */   select '3.14' similar to E'^\\d+\\.\\d+$';       -- true
/* (2) */   select '3.14' similar to E'^\\d+(\\.\\d+)$';     -- true
/* (3) */   select '3.14' similar to E'^\\d+(\\.\\d+)*$';    -- true
/* (4) */   select '3.14' similar to E'^\\d+(\\.\\d+)?$';    -- false
/* (5) */   select '3.14' similar to E'^\\d+(\\.\\d+)+$';    -- true

So, based on (1) and (2), the pattern '\.\d+' occurs once.  So why does
(4) return false?  between (3), (4), and (5), it appears as though the
group is matching multiple times.

Thanks,

--
------------------------------------------------------------------------
*Doug Gorley* | doug.gorley@gmail.com <mailto:doug.gorley@gmail.com>



pgsql-general by date:

Previous
From: "Spotts, Christopher"
Date:
Subject: array_agg performance
Next
From: Merlin Moncure
Date:
Subject: Re: interface for "non-SQL people"