On Tue, Aug 10, 1999 at 01:59:56PM -0400, Bill Jones wrote: > Given: > > s{((\d+\.)(?:\d+)+)} {<A HREF="nav$2html">$1</A>}g; > > Why does the first match '$1" get the whole match, and > '$2' is getting the partial (which I feel is arriving > from the first (\d+\.) ? Capturing parentheses count from the left: m/((\d+\.)(?:\d+)+)/ 11111111111111111 2222222 > However, this new match isn't really picking up the > complete first match. IE - > > I have 1.2 and it matches 1.2 and 1. respectively; > but when I have 1.2.3 - the .3 is lost... Your regex only allows a single period. You can't match all of '1.2.3', because that contains two periods. > Where 1.2.3.? = book.chapter.section.keyword.et al... > > What I wanted was - > > $1 = complete match, $2 = book and chapters, etc. m/((\d+)(?:\.\d+)+)/; > (or, maybe have $3 = chapters, and $4 = sections?) You can't do that without knowing how many pieces you want ahead of time. Try this instead: if (m/(\d+(?:\.\d+)+)/) { @pieces = split /\./, $1; } > I even tried: > > (?=\d+(?:\.\d+)+) but then nothing shows up in $2... No capturing parentheses at all. Nothing will show up in $1 either. Ronald ==== Want to unsubscribe from Fun With Perl? Well, if you insist... ==== Send email to <fwp-request@technofile.org> with message _body_ ==== unsubscribe