Thank you Francisco. In fact, I am already solving part of the problem in my application - fetching from the DB the records matching the source pattern and then filtering them in the application's memory by matching against the target pattern, with the references replaced (it's a breeze in C#). It works very vell. However, I am not completely satisfied with i as it's unnecessarily loading larger data set than it absolutely must. Besides, I'd also like to get some experience in DB programming. That's why the PL/Perl way seems pretty attractive to me. -- View this message in context: http://postgresql.1045698.n5.nabble.com/Emulating-flexible-regex-replace-tp5824058p5824174.html Sent from the PostgreSQL - general mailing list archive at Nabble.com. -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general