my scenario is this: I have a *SEGMENT* table with two text fields, *source* and *target*. From the user, I get the following input:
/source pattern/ /target pattern/
Where both patterns are regexes and moreover the target pattern contains references to the source in the following way:
Supposing *source* matches the /source pattern/, the $/n/ expressions inside the /target pattern/ correspond to the captured groups inside *source*.
*If* you have some available char sequence which is not going to be in any of them and your regexp are not too esoteric, you could just try to match source || 'XyZzYX' || target against source_pattern || 'XyZzYX' || target_pattern, replace separator as needed.
If your patterns are ( not ) anchored you may need to insert some .* / ^ / $ and multiline modifiers, but this normally works for me ( in perl normally, but should be easy to do ).
Your performance maybe really bad if your tables are big and you have no more conditions, but any query with general patterns tend to behave this way.