Given an input like one of the following, I need to check if it matches given text, of the format 'ABCD1234':
- ABCD1### matches ABCD1943, ABCD1300, but does not match ABCD2042 or FOOB3075
- DCBA[98]### matches DCBA9012, DCBA8899 but not DCBA6211
- ####1### matches ABCD1848 and BARR1093
- (ABCD|FOOB|BARR)2### matches ABCD2999, FOOB2533, BARR2222
- ABCD1234,WXYZ9876 matches only ABCD1234, WXYZ9876
- DCBA9###,DCBA8### matches the same things as DCBA[98]### above
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.