my $str1 = "beer=10&otherstuff&vodka=20&otherstuff&chips=100"; my $str2 = "beer=10&otherstuff&juice=20&otherstuff&chips=100"; my $re = qr/beer=(\d{2}).*((vodka|juice)=(\d{2})).*chips=(\d{3})/; { $str1 =~ /$re/ ? print "matches\n" : print "doesn't match\n"; print "$1 $2 $3 $4 \n"; } { $str2 =~ /$re/? print "matches\n" : print "doesn't match\n"; print "$1 $2 $3 $4 \n"; }
is that what you want???matches 10 vodka=20 vodka 20 matches 10 juice=20 juice 20
In reply to Re: Likely trivial regex question
by ansh batra
in thread Likely trivial regex question
by moodywoody
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |