in reply to Likely trivial regex question

Is that a URL-encoded form?

use URI qw( ); my %fields = URI->new('?'.$str)->query_form(); say "fields present" if exists($fields{ beer }) && exists($fields{ vodka }) && exists($fields{ chips }); say "matches" if ($fields{ beer } // "") =~ /^(?:[0-9]{2})\z/ && ($fields{ vodka } // "") =~ /^(?:[0-9]{2})\z/ && ($fields{ chips } // "") =~ /^(?:[0-9]{3})\z/;

Replies are listed 'Best First'.
Re^2: Likely trivial regex question
by moodywoody (Novice) on Nov 09, 2011 at 07:04 UTC
    No, the original data are tomcat logs with URL requests.
      What you posted aren't logs. You do seem to confirm that these are URL fragments though. Are you saying you don't know how to extract these URLs fragments from the logs?
        No. I created an abstract example. What I am saying is that I don't know how to consistently capture optional groupings.