in reply to Re: Reg ex question
in thread Reg ex question

/\d+(\d+\d+)\d+/ will store the 2nd and 3rd digits in $1 only on a 4 digit number. and if you are only dealing with 4 digit numbers then the regex can be more simply written as /\d(\d\d)\d/. the + sign refers to one or more occurrences of the preceding thing. what you will find is that if you have a number of more than 4 digits your regex will match the third-last and second-last. this is because perl's regexes are "greedy" so the first \d+ will suck up as many digits as it can before backtracking to allow the rest to match. again, this could be more simply written as /\d+(\d\d)\d/.

larryk $less->{'chars'} = `"time in the pub" | more`; # :-D