Reputation: 229
Given an input like one of the following, I need to check if it matches given text, of the format 'ABCD1234':
I'm writing this like a function that has the following structure:
create or replace function modifiedRegEx(pattern text, tester text)
RETURNS boolean
AS $re$
DECLARE
isMatch boolean;
BEGIN
isMatch := TRUE;
return isMatch;
END;
$re$ LANGUAGE 'plpgsql';
Obviously the above will return TRUE
every time. I was wondering if anyone could please suggest some string functions that might be helpful in checking the above? I'm at a loss, even after reading the PostgreSQL string functions docs.
Thank you.
Upvotes: 0
Views: 61
Reputation: 1144
Your answer is here: http://www.postgresql.org/docs/9.0/static/functions-matching.html
This one returns true:
SELECT 'DCBA9012' similar to 'DCBA[98]___';
or:
SELECT 'DCBA9012' ~ 'DCBA[98]...';
Upvotes: 2