[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

RE: [FWP] Is this fun? What's going on?



> From: Prakash Kailasa [mailto:PrakashK@bigfoot.com]
> Sent: Friday, August 06, 1999 09:26
> To: Bill Jones
> Cc: Fun With Perl
> Subject: Re: [FWP] Is this fun? What's going on?
> 
> Bill Jones wrote:
> > 
> > [..deleted..]
> >
> > On a related note -
> > 
> > s{(\d+\.\d+)}  {<A HREF="$1">$1</A>}g;
> > 
> > What can I change to also match an optional
> > third or fourth  (  #.#.#  or #.#.#.# ) section number???
> 
> 	s{(\d+(\.\d+)+)} {<A HREF="$1">$1</A>};
> will match any number of #.#... sequences
> 
> If you want to limit that to 4 levels only,
> 	s{(\d+(\.\d+){2,4})} {<A HREF="$1">$1</A>};

                    1,3

And slightly more stylish to make the inner parens non-capturing, as
others have shown:

> 	s{(\d+(?:\.\d+){1,3})} {<A HREF="$1">$1</A>};

-- 
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com 

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe