[tpm] quicky regex question

Fulko Hew fulko.hew at gmail.com
Wed Sep 22 11:06:55 PDT 2010


On Wed, Sep 22, 2010 at 2:03 PM, Fulko Hew <fulko.hew at gmail.com> wrote:

> given the sample pattern:
>
> 00.99.88.77.66.55.44.33.22.11
>
> and I wanted to extract the 'n' amount of number-dot sequences
> how do I do it?
>
> I tried something like /^(\d*\.){$n}/
> but that only got me the 'nth' number, not everything preceding it also.
>
> ie if n=7
>
> I want:   '00.99.88.77.66.55.44'
> not just:
>  '.44'
>

Nevermind... that neuron finally decided to fire!
The answer is an extra set of 'capture'.  Ie.

/^((\d*\.)){$n}/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/toronto-pm/attachments/20100922/66028d41/attachment.html>


More information about the toronto-pm mailing list