Re: Replacing Ordinal Suffixes - Mailing list pgsql-general

From George Weaver
Subject Re: Replacing Ordinal Suffixes
Date
Msg-id FAEBBD2CD21D4386B7CB672FBB5140B5@D420
Whole thread Raw
In response to Re: Replacing Ordinal Suffixes  ("George Weaver" <gweaver@shaw.ca>)
Responses Re: Replacing Ordinal Suffixes  (Ian Lawrence Barwick <barwick@gmail.com>)
List pgsql-general
>----- Original Message -----
>From: Steve Atkins

>On Feb 28, 2014, at 2:43 PM, George Weaver <gweaver@shaw.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...

>Cheers,
 > Steve



--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



pgsql-general by date:

Previous
From: Steve Atkins
Date:
Subject: Re: Replacing Ordinal Suffixes
Next
From: Rich Shepard
Date:
Subject: Moving data from M$ JetDB file to Postgres on Linux