in reply to Re: Regex to find the number of positive, negative, and 0 integers within a data set
in thread Regex to find the number of positive, negative, and 0 integers within a data set

Thanks for the post! I came up with the regex for the positive ints.

while( my $num = <DATA> ) { chomp($num); ## print "num=[$num]\n"; if ( $num =~ /^[1-9]\d*$/ ) { $ctrP++; }

I would like for it to be in regular expressions so that I can learn how to use them properly. I am having trouble so that the regex for the negative ints finds only negative ints.

  • Comment on Re^2: Regex to find the number of positive, negative, and 0 integers within a data set
  • Download Code

Replies are listed 'Best First'.
Re^3: Regex to find the number of positive, negative, and 0 integers within a data set
by stevieb (Canon) on Feb 28, 2017 at 17:59 UTC