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

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



On Fri, Aug 06, 1999 at 10:49:12AM -0400, Bill Jones wrote:
> s{(\d+\.\d+)}  {<A HREF="$1">$1</A>}g;
> 
> What can I change to also match an optional
> third or fourth  (  #.#.#  or #.#.#.# ) section number???
> 
> I am looking at various forms of -
> s{(\d+\.\d+){1}(\.\d+)?(\.\d+)?}  {<A HREF="$1">$1</A>}g;
> 
> But that actually truncates the results...
> 

$1 only encompasses the first part of the regex.  You need capturing
parentheses around the whole thing.

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

BTW, instead of {1}, you could have written {1,1}.
Or even {1,1}?.   ;)

Ronald

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