From: | Ian Lawrence Barwick <barwick(at)gmail(dot)com> |
---|---|
To: | George Weaver <gweaver(at)shaw(dot)ca> |
Cc: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Replacing Ordinal Suffixes |
Date: | 2014-02-28 23:33:03 |
Message-ID: | CAB8KJ=gb5LS8-U1BovvULPxfjCWXd9G3E0LO2zOVDNR6AuKb=Q@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
2014-03-01 8:16 GMT+09:00 George Weaver <gweaver(at)shaw(dot)ca>:
>
>> ----- Original Message ----- From: Steve Atkins
>
>
>> On Feb 28, 2014, at 2:43 PM, George Weaver <gweaver(at)shaw(dot)ca> wrote:
>>
>> >Maybe this?
>>
>> >select regexp_replace('300 North 126th Street', '(\d+)(?:st|nd|rd|th)',
>> >'\1', 'gi');
>>
>> Hi Steve,
>>
>> Thanks, but no luck:
>>
>> select regexp_replace('300 North 126th Street', E'(\d+)(?:st|nd|rd|th)',
>> E'\1', 'gi');
>> regexp_replace
>> ------------------------
>> 300 North 126th Street
>>
>> George
>
>
>> Those E’s you added completely change the meaning. If you want to
>> use E-style literals (and you probably don’t) you’ll need to double the
>> backslashes in all the strings.
>
>
> Hi Steve,
>
> Without the E's:
>
> development=# select regexp_replace('300 North 126th Street',
> '(\d+)(?:st|nd|rd|th)', '\1', 'gi');
> WARNING: nonstandard use of escape in a string literal
> LINE 1: select regexp_replace('300 North 126th Street', '(\d+)(?:st|...
> ^
> HINT: Use the escape string syntax for escapes, e.g., E'\r\n'.
> WARNING: nonstandard use of escape in a string literal
> LINE 1: ...'300 North 126th Street', '(\d+)(?:st|nd|rd|th)', '\1', 'gi'...
> ^
> HINT: Use the escape string syntax for escapes, e.g., E'\r\n'.
>
> regexp_replace
> ------------------------
> 300 North 126th Street
> (1 row)
>
> Frustrating...
Per Steve Atkin's note about double backslashes:
postgres=> select regexp_replace('300 North 126th Street',
E'(\\d+)(?:st|nd|rd|th)', E'\\1', 'gi');
regexp_replace
----------------------
300 North 126 Street
(1 row)
Regards
Ian Barwick
From | Date | Subject | |
---|---|---|---|
Next Message | Adrian Klaver | 2014-02-28 23:45:35 | Re: Moving data from M$ JetDB file to Postgres on Linux |
Previous Message | Rich Shepard | 2014-02-28 23:21:26 | Moving data from M$ JetDB file to Postgres on Linux |