Create a gist now

Instantly share code, notes, and snippets.

@jeff /nix0n.sql Secret
Created Aug 12, 2015

What would you like to do?
CREATE OR REPLACE FUNCTION plv8_regexp_test(regexp text[2], subject text) RETURNS BOOLEAN AS $$
return (new RegExp(regexp[0], regexp[1])).test(subject);
$$ LANGUAGE plv8;
CREATE OR REPLACE FUNCTION plv8_regexp_test(regexp text, subject text) RETURNS BOOLEAN AS $$
BEGIN
RETURN plv8_regexp_test(ARRAY[regexp], subject);
END;
$$ LANGUAGE plpgsql;
SELECT id, date_added, name
FROM testable
WHERE plv8_regexp_test('^d', name);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment