regex in plpgsql function

From: Culley Harrelson <culley(at)fastmail(dot)fm>
To: pgsql-general(at)postgresql(dot)org
Subject: regex in plpgsql function
Date: 2004-01-22 17:36:14
Message-ID: 20040122173614.GB29114@abcteach.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I am using 7.4.1

Basically I am trying to use a regex that will match:

john smith
john r smith
john r. smith

When I use:

siteadmin=# select 'john r. smith' ~ '^\\w+\\s+\\w?\\.?\\s?\\w+$';
?column?
----------
t
(1 row)

all is well but:

CREATE OR REPLACE FUNCTION f_tmp(TEXT) RETURNS BOOLEAN AS ' --{{{

BEGIN
RETURN $1 ~ ''^\\w+\\s+\\w?\\.?\\s?\\w+$'';
END;
' language 'plpgsql';

siteadmin=# select f_tmp('john r. smith');
f_tmp
-------
f
(1 row)

makes the same regex seem to behave differently. What am I doing wrong?

culley

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bruno Wolff III 2004-01-22 17:56:10 Re: trust auth in 7.4
Previous Message Tom Lane 2004-01-22 17:31:30 Re: Lost plpgsql function