From: | David Fetter <david(at)fetter(dot)org> |
---|---|
To: | SF Postgres <sfpug(at)postgresql(dot)org> |
Subject: | Re: Regular Expression Help? |
Date: | 2003-11-05 15:22:35 |
Message-ID: | 20031105152235.GU14711@fetter.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | sfpug |
On Tue, Nov 04, 2003 at 08:56:29PM -0800, David Wheeler wrote:
> 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 %replacements.
D'oh! I missed that.
> >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!
That makes sense--after all, why would it compile more than once?
Cheers,
D
--
David Fetter david(at)fetter(dot)org http://fetter.org/
phone: +1 510 893 6100 cell: +1 415 235 3778
From | Date | Subject | |
---|---|---|---|
Next Message | Josh Berkus | 2003-11-05 17:48:33 | Re: Regular Expression Help? |
Previous Message | David Wheeler | 2003-11-05 04:56:29 | Re: Regular Expression Help? |