| From: | Doug Gorley <doug(dot)gorley(at)gmail(dot)com> |
|---|---|
| To: | pgsql-general(at)postgresql(dot)org |
| Subject: | Regexp confusion |
| Date: | 2009-10-09 21:36:46 |
| Message-ID: | 4ACFACEE.8050001@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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(dot)gorley(at)gmail(dot)com <mailto:doug(dot)gorley(at)gmail(dot)com>
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Merlin Moncure | 2009-10-09 21:56:15 | Re: interface for "non-SQL people" |
| Previous Message | Spotts, Christopher | 2009-10-09 20:27:14 | array_agg performance |