Emulating flexible regex replace

Поиск
Список
Период
Сортировка
От Francisco Olarte
Тема Emulating flexible regex replace
Дата
Msg-id CA+bJJbyRE8_kzrCQCd0do=JLA4s-xL1UodDuXMCVgAFnVceVhA@mail.gmail.com
обсуждение исходный текст
Ответы Re: Emulating flexible regex replace  (twoflower <standa.kurik@gmail.com>)
Список pgsql-general
( Forgot reply all, forwarding a copy, sorry for the noise. )

Hullo.

On Thu, Oct 23, 2014 at 4:03 PM, twoflower <standa.kurik@gmail.com> 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.


В списке pgsql-general по дате отправления:

Предыдущее
От: David G Johnston
Дата:
Сообщение: Re: Emulating flexible regex replace
Следующее
От: David G Johnston
Дата:
Сообщение: Re: Emulating flexible regex replace