PCRE: references to captures in replace string

imad hajj chahine imad.hajj.chahine at gmail.com
Tue Apr 26 16:57:05 CEST 2016


I still find this to be an interested feature to add, as its very useful in
string date manipulation.

On Tue, Apr 26, 2016 at 5:28 PM, Roberto Cornacchia <
roberto.cornacchia at gmail.com> wrote:

> I found this thread from October 2015 where Sjoerd concludes that back
> references replacement is not implemented in the MonetDB wrapper:
> https://www.monetdb.org/pipermail/users-list/2015-October/008492.html
>
> Probably that is still the case?
>
> On 20 April 2016 at 16:35, Roberto Cornacchia <
> roberto.cornacchia at gmail.com> wrote:
>
>> After declaring a wrapper for pcre.replace:
>>
>> sql>create function pcre_replace(s string, pattern string, repl string,
>> flags string) returns string external name pcre."replace";
>> operation successful (6.187ms)
>>
>> I cannot get replacements with references to captures work (but the code
>> in pcre.c seems to support it):
>>
>> sql>select pcre_replace('Apple Pear', '^([a-zA-Z]+)\\s*([a-zA-Z]+)$',
>> '\\1 \\2', '');
>> +---------------------------+
>> | pcre_replace_single_value |
>> +===========================+
>> | \1 \2                     |
>> +---------------------------+
>> 1 tuple (0.309ms)
>>
>> The pattern is matched, but the back references are replaced literally.
>> Am I not getting the syntax correct?
>> From http://www.pcre.org/original/doc/html/pcresyntax.html I see I could
>> use any of \1, \g1, \g{1] for back references, but none seem to work.
>>
>> Roberto
>>
>>
>
> _______________________________________________
> users-list mailing list
> users-list at monetdb.org
> https://www.monetdb.org/mailman/listinfo/users-list
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.monetdb.org/pipermail/users-list/attachments/20160426/0c988d7b/attachment.html>


More information about the users-list mailing list