Re: [GENERAL] Replacing Ordinal Suffixes

2014-03-01 Thread George Weaver
- Original Message - From: Steve Atkins I suspect you have standard_conforming_strings set to off (it defaults to on in 9.1), possibly for backwards compatibility to support an app you’re using that’s not been updated, possibly accidentally. You're right - it was off (now On). Th

Re: [GENERAL] Replacing Ordinal Suffixes

2014-03-01 Thread Steve Atkins
On Mar 1, 2014, at 11:45 AM, George Weaver wrote: > >> Actually, I found that the double backslashes are required whether the E is >> used or not: > >> You must be using a relatively old PG version then. Default behavior >> since around 9.1 has been that backslashes aren't special except >> i

Re: [GENERAL] Replacing Ordinal Suffixes

2014-03-01 Thread George Weaver
Actually, I found that the double backslashes are required whether the E is used or not: You must be using a relatively old PG version then. Default behavior since around 9.1 has been that backslashes aren't special except in E'' strings. Hmm. development=# select version();

Re: [GENERAL] Replacing Ordinal Suffixes

2014-03-01 Thread Tom Lane
"George Weaver" writes: > Actually, I found that the double backslashes are required whether the E is > used or not: You must be using a relatively old PG version then. Default behavior since around 9.1 has been that backslashes aren't special except in E'' strings. reg

Re: [GENERAL] Replacing Ordinal Suffixes

2014-03-01 Thread George Weaver
Hi All, From: James Cloos The E'' syntax eats your backslashes. For that version, try just: SELECT REGEXP_REPLACE(LOWER('300 North 126th Street'),'(\d)(st|nd|rd|th)', '\1', 'g'); Actually, I found that the double backslashes are required whether the E is used or not: development=# se

Re: [GENERAL] Replacing Ordinal Suffixes

2014-03-01 Thread Alvaro Herrera
George Weaver wrote: > Hi Ian, > > I just got that as well - awesome! http://xkcd.com/1313/ -- Álvaro Herrerahttp://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make ch

Re: [GENERAL] Replacing Ordinal Suffixes

2014-02-28 Thread James Cloos
> "GW" == George Weaver writes: GW> SELECT REGEXP_REPLACE(LOWER('300 North 126th Street'), GW> E'(\d)(st|nd|rd|th)', E'\1', 'g'); GW> regexp_replace GW> GW> 300 north 126th street GW> (1 row) The E'' syntax eats your backslashes. For that version, try just: SEL

Re: [GENERAL] Replacing Ordinal Suffixes

2014-02-28 Thread George Weaver
From: Ian Lawrence Barwick - Original Message - From: Steve Atkins On Feb 28, 2014, at 2:43 PM, George Weaver 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 No

Re: [GENERAL] Replacing Ordinal Suffixes

2014-02-28 Thread Ian Lawrence Barwick
2014-03-01 8:16 GMT+09:00 George Weaver : > >> - Original Message - From: Steve Atkins > > >> On Feb 28, 2014, at 2:43 PM, George Weaver wrote: >> >> >Maybe this? >> >> >select regexp_replace('300 North 126th Street', '(\d+)(?:st|nd|rd|th)', >> >'\1', 'gi'); >> >> Hi Steve, >> >> Thanks, b

Re: [GENERAL] Replacing Ordinal Suffixes

2014-02-28 Thread George Weaver
- Original Message - From: Steve Atkins To: pgsql-general Sent: Friday, February 28, 2014 4:17 PM Subject: Re: [GENERAL] Replacing Ordinal Suffixes On Feb 28, 2014, at 2:04 PM, George Weaver wrote: Hi list, I'm stumped. I am trying to use Regexp_Replace to replace or

Re: [GENERAL] Replacing Ordinal Suffixes

2014-02-28 Thread George Weaver
- Original Message - From: Steve Atkins On Feb 28, 2014, at 2:43 PM, George Weaver 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+)(?:

Re: [GENERAL] Replacing Ordinal Suffixes

2014-02-28 Thread Steve Atkins
On Feb 28, 2014, at 2:43 PM, George Weaver wrote: > From: Steve Atkins > > >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

Re: [GENERAL] Replacing Ordinal Suffixes

2014-02-28 Thread George Weaver
From: Steve Atkins On Feb 28, 2014, at 2:04 PM, George Weaver wrote: > Hi list, > > I'm stumped. > > I am trying to use Regexp_Replace to replace ordinal suffixes in addresses > (eg have '126th' want '126') for comparison purposes. So far no luck. > > I have found that > > SELECT REGEXP_REPLAC

Re: [GENERAL] Replacing Ordinal Suffixes

2014-02-28 Thread George Weaver
From: Paul Jungwirth Try this: SELECT REGEXP_REPLACE(LOWER('300 North 126th Street'), '(\d)(st|nd|rd|th)', '\1', 'g'); Hi Paul, No luck... SELECT REGEXP_REPLACE(LOWER('300 North 126th Street'), E'(\d)(st|nd|rd|th)', E'\1', 'g'); regexp_replace 300 north 126t

Re: [GENERAL] Replacing Ordinal Suffixes

2014-02-28 Thread Bret Stern
This is a kick *ss forum. I must say. On Fri, 2014-02-28 at 14:17 -0800, Steve Atkins wrote: > On Feb 28, 2014, at 2:04 PM, George Weaver wrote: > > > Hi list, > > > > I'm stumped. > > > > I am trying to use Regexp_Replace to replace ordinal suffixes in addresses > > (eg have '126th' want

Re: [GENERAL] Replacing Ordinal Suffixes

2014-02-28 Thread Steve Atkins
On Feb 28, 2014, at 2:04 PM, George Weaver wrote: > Hi list, > > I'm stumped. > > I am trying to use Regexp_Replace to replace ordinal suffixes in addresses > (eg have '126th' want '126') for comparison purposes. So far no luck. > > I have found that > > SELECT REGEXP_REPLACE(LOWER('30

Re: [GENERAL] Replacing Ordinal Suffixes

2014-02-28 Thread Paul Jungwirth
Try this: SELECT REGEXP_REPLACE(LOWER('300 North 126th Street'), '(\d)(st|nd|rd|th)', '\1', 'g'); Note that matching a number is \d not /D: backslash, not forward slash, and lowercase d not uppercase. \d means a digit, \D means anything except a digit. Also, I don't think Postgres supports posit

[GENERAL] Replacing Ordinal Suffixes

2014-02-28 Thread George Weaver
Hi list, I'm stumped. I am trying to use Regexp_Replace to replace ordinal suffixes in addresses (eg have '126th' want '126') for comparison purposes. So far no luck. I have found that SELECT REGEXP_REPLACE(LOWER('300 North 126th Street'), '(?!/D)(st|nd|rd|th)', '', 'g'); regexp_replace -