in reply to Re^3: seeking improvement in my smiple program using regular expression
in thread seeking improvement in my smiple program using regular expression

the following may do the trick:

s{ ((?: [^ ]+ \s+ ){17}) \d{1,3} (\s+ \d+) $} {$1$count$2}x;

just a few points, some of which have been made before...

all these regexes are untested.

Replies are listed 'Best First'.
Re^5: seeking improvement in my smiple program using regular expression
by BrowserUk (Patriarch) on Aug 06, 2007 at 06:06 UTC

    Repeated captures do not work. Only the last repetition actually captures anything. Contrast:

    my @captures = 'abcde' =~ m[(.){3}]; print "@captures";; c

    with

    my @captures = 'abcde' =~ m[(.)(.)(.)];; print "@captures";; a b c

    and

    'abcde' =~ m[(.){3}] and print "$1,$2,$3";; Use of uninitialized value in concatenation (.) or string at ... Use of uninitialized value in concatenation (.) or string at ... c,, 'abcde' =~ m[(.)(.)(.)] and print "$1,$2,$3";; a,b,c
    all these regexes are untested.

    You might consider revising that policy.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.