Re: regexp_replace puzzle

From: David W Noon <dwnoon(at)ntlworld(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: regexp_replace puzzle
Date: 2010-03-10 16:57:07
Message-ID: 20100310165707.5ba9863c@dwnoon.ntlworld.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, 10 Mar 2010 13:41:54 +0100, Harald Fuchs wrote about [GENERAL]
regexp_replace puzzle:

[snip]
> SELECT val,
> regexp_replace(val,
> '^(.*\W)?(C\d{7}|[DI]\d{6}|S\d{10})(\W.*)?$',
> '\1' || '»\2«='|| sha224enc('\2') || '\3', 'i')
[snip]
>i.e. the first '\2' gets properly expanded by the second paren match,
>but the second '\2' doesn't get expanded.

The second instance of '\2' is first passed to sha224enc(), then that
function's result is passed to regexp_replace.
--
Regards,

Dave [RLU #314465]
=======================================================================
david(dot)w(dot)noon(at)ntlworld(dot)com (David W Noon)
=======================================================================

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Steve Crawford 2010-03-10 17:03:20 Re: How to? Timestamp with timezone.
Previous Message Ben Chobot 2010-03-10 16:55:09 Re: log_statement and syslog severity