Reputation: 45
I am trying to use qr function in perl and also want to do Case insensitive regex matching. Below is what I am trying to do:
my $pattern = qr(Buy Qty\[([0-9]+\.?[0-9]*)\]);
my $logPattern = "BUY Qty[200000] On merchant site";
if($logPattern =~ /$pattern/i){
print "MatchFound, Qty is ==> $1";
else {
print "Match Not found";
}
However When I run this, it gives me "Match Not found" as it is not making this regex match as case insensitive. However if I remove the qr code and use the same pattern , it gives me the correct answer.
Please do let me know what I am missing here.
Upvotes: 2
Views: 761
Reputation: 50637
You have to compile regex with /i
switch
my $pattern = qr(Buy Qty\[([0-9]+\.?[0-9]*)\])i;
Upvotes: 1