Passing function parameters to regexp_replace - Mailing list pgsql-sql

From Leif Biberg Kristensen
Subject Passing function parameters to regexp_replace
Date
Msg-id 201109171321.43309.leif@solumslekt.org
Whole thread Raw
Responses Re: Passing function parameters to regexp_replace
List pgsql-sql
I'm trying to write a sql or plpgsql function update_nametags(TEXT, TEXT) 
which does a replace on this form:

UPDATE sources SET source_text = regexp_replace(source_text, 
E'n="(.*?)$1(.*?)"', E'n="\\1$2\\2"', 'g') where source_text like 
'%n="%$2%">%';

But I can't find out how to escape the parameters $1 and $2. I've also tried to 
wrap it in an EXECUTE and concatenate the parameters with no luck.

I'd also like to have the function return the number of affected rows.

regards, Leif


pgsql-sql by date:

Previous
From: Tim Landscheidt
Date:
Subject: Re: Window function sort order help
Next
From: Leif Biberg Kristensen
Date:
Subject: Re: Passing function parameters to regexp_replace