Search Postgresql Archives

Emulating flexible regex replace

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



( Forgot reply all, forwarding a copy, sorry for the noise. )

Hullo.

On Thu, Oct 23, 2014 at 4:03 PM, twoflower <standa.kurik@xxxxxxxxx> wrote:

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.

Francisco Olarte.



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux