Re: back references using regex

From: Matthew Peter <survivedsushi(at)yahoo(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: back references using regex
Date: 2005-09-10 17:27:13
Message-ID: 20050910172713.23245.qmail@web35210.mail.mud.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

ahhhhhhhhh I swear I never came across any of these
gems of information in the docs. It was these subtle
differences that were throwing me.

I didn't originally catch that regex's were based on
grep/sed/awk syntax which I haven't studied throughly
yet. I've only used some basic operations in bash
scripts. I'll read up more on those. Thanks.

MP

--- Douglas McNaught <doug(at)mcnaught(dot)org> wrote:

> Matthew Peter <survivedsushi(at)yahoo(dot)com> writes:
>
> > One other thing, when I wrote back I actually used
> > 34.31.29.20 (random), not 12.00.00.34 like i
> showed in
> > the example, which is why i said it didn't work on
> > digits.
> >
> > SELECT substring('34.31.29.20' FROM
> $$((\w+)\.\2)$$);
> > substring
> > -----------
> >
> > (1 row)
> >
> > little did i know writing it with 12.00.00.34
> would
> > return 00.00... so yes, that did suprise me.
> > Apparently only using the identical values returns
> a
> > value. so it's saying x+ one more of the same
> value
> > separated by a period... where shouldn't it be any
> > "letter, number or underscore" followed by any
> > "letter, number or underscore"?
>
> Backreferences match the exact string matched by the
> corresponding set
> of parentheses. It's not the equivalent of
> substituting in the
> parenthesized part of the regex and testing that for
> a match. The
> behavior above is as expected. If you want it as
> "any followed by
> any" you shold write the regex as '((\w+)\.(\w+))'
> -- then the two
> parts can differ.
>
> -Doug
>



______________________________________________________
Click here to donate to the Hurricane Katrina relief effort.
http://store.yahoo.com/redcross-donate3/

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Michael Schmidt 2005-09-10 18:25:52 Re: EMS PostgreSQL Manager vs. TheKompany DataArchitect
Previous Message brew 2005-09-10 17:25:03 Re: Postgresql Hosting