in reply to Regex to match string with numbers with possible comma

Is there any reason to worry about what's between "found" and "results"? Unless it might come back with "found pig results" and you don't want to match on that, just:
=~ /found (.*) results/;
See also this node for how to match properly-formatted numbers with commas.

The PerlMonk tr/// Advocate

Replies are listed 'Best First'.
Re: Re: Regex to match string with numbers with possible comma
by rir (Vicar) on Mar 17, 2004 at 17:24 UTC
    .* is greedy, consider the string found 10 results blah blah found 1,000 results. Generally .* is a subpattern to be suspicious of; I would implement your idea with something like /found (.{1,12}) results/ or /found (.*?) results/.
      We're talking about a fairly predictable response, where I wouldn't expect to see multiple "found" messages. You provide one easy fix with *?. Another is:/found \S+ results/

      The PerlMonk tr/// Advocate