The substring function with two parameters, substring(string from pattern), provides extraction of a substring that matches a POSIX regular expression pattern. It returns null if there is no match, otherwise the portion of the text that matched the pattern. But if the pattern contains any parentheses, the portion of the text that matched the first parenthesized subexpression (the one whose left parenthesis comes first) is returned. You can put parentheses around the whole expression if you want to use parentheses within it without triggering this exception.
A less-fragile way to do this is to comparing length of whole string to length of matched string. See below.
For the greater good I sent the email requesting to allow reg exp in the position functions. Not sure if you will implement it... Just wanted to let you know that the limited capabilities of this function create overhead.
Not clear to me if you're talking CPU overhead or syntax complexity. But if you really want this function for yourself, you can have it.
CREATE OR REPLACE FUNCTION position_regex (text, text) RETURNS INT AS $$
SELECT COALESCE(LENGTH($2)-LENGTH(SUBSTRING($2,'('||$1||'.*)$'))+1,0);
$$ LANGUAGE SQL IMMUTABLE;