in reply to What does this regex do?

OK. I assume that you understand the while loop part of it, so just the regex:
$interest !~ / # match against $interest (negated) ^ # start of line -? # optional minus sign \.? # optional decimal point \d+ # 1 or more digits (?: # start non-capturing group (i.e. not $1) \. # decimal point \d+ # 1 or more digits )? # end of group -- match 0 or 1 times $ # end of line /x; # end of regex (the /x modifier allows # comments in the regex -- can be useful)
So thats what the regex does. But it doesn't look quite right for its stated purpose -- for example, your numbers could have two decimal points. --Dave

Replies are listed 'Best First'.
Re: Re: What does this regex do?
by dpuu (Chaplain) on Apr 01, 2003 at 19:44 UTC
    One more thing: you might want to look at Damian Conway's Regexp::Common package: it contains working regexes for many common situations (such as matching numbers). --Dave