Skip site navigation (1) Skip section navigation (2)

Re: Regular Expression Help?

From: David Wheeler <david(at)kineticode(dot)com>
To: David Fetter <david(at)fetter(dot)org>
Cc: SF Postgres <sfpug(at)postgresql(dot)org>
Subject: Re: Regular Expression Help?
Date: 2003-11-05 04:56:29
Message-ID: (view raw, whole thread or download thread mbox)
Lists: sfpug
On Tuesday, November 4, 2003, at 08:50  PM, David Fetter wrote:

>>> $eline =~ s/(#\w+)/$replacements{$1} || $1/ge;
> I'd be a little scared to use this one because #\w+ matches more
> things than I know about for sure.

Yes, but I've allowed for that by just using $1 if it doesn't exist in 

> It might be a little less maintenance to do something like
> $match = qr{ "(". join("|", keys %replacements) . ")" }o;
> $eline =~ s/$match/$replacements{$1}/g;

Yeah, that's cool, too, although the terminal "o" probably isn't 
needed, because a qr// is defined once by default!



David Wheeler                                     AIM: dwTheory
david(at)kineticode(dot)com                              ICQ: 15726394                     Yahoo!: dew7e
                                                Jabber: Theory(at)jabber(dot)org
Kineticode. Setting knowledge in motion.[sm]

In response to


sfpug by date

Next:From: David FetterDate: 2003-11-05 15:22:35
Subject: Re: Regular Expression Help?
Previous:From: David FetterDate: 2003-11-05 04:50:16
Subject: Re: Regular Expression Help?

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group