|
Home > Archive > PostgreSQL Bugs > December 2005 > BUG #2127: Regular Expression Limits Do Not Work
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
BUG #2127: Regular Expression Limits Do Not Work
|
|
| Kyril Alyoshin 2005-12-27, 9:23 am |
|
The following bug has been logged online:
Bug reference: 2127
Logged by: Kyril Alyoshin
Email address: kyrill@technolog.ca
PostgreSQL version: 8.0.3
Operating system: Windows XP
Description: Regular Expression Limits Do Not Work
Details:
I am writing a regex to verify US zipcodes. The expression is very simple,
in a trigger function it looks like this:
IF (NEW.postal_code_name !~ '\\d{5}')
THEN
RAISE EXCEPTION 'error';
END IF;
The bug description is:
If postal_code_name is > 5 digits, the expression would still evaluate to
false, and the error will not be raised.
Please correct this.
Thank you.
Kyrill
---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match
| |
| Tom Lane 2005-12-27, 9:24 am |
| "Kyril Alyoshin" <kyrill@technolog.ca> writes:
> IF (NEW.postal_code_name !~ '\\d{5}')
> The bug description is:
> If postal_code_name is > 5 digits, the expression would still evaluate to
> false, and the error will not be raised.
> Please correct this.
Please learn how to use regular expressions ;-)
You probably want '^\\d{5}$' instead, to require the regex to match the
whole string instead of just any part of it.
regards, tom lane
---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?
http://www.postgresql.org/docs/faq
|
|
|
|
|