in reply to difference between "*." and "." operators
As said - not sure what your intention is.#!/usr/bin/perl use strict; use warnings; my $string = "abcABC123ABCabc"; # the following is using shell commands # to do something perl can do much better... echo `expr match "$string" 'abc[A-Z]*.2'` ; echo `expr match "$string" 'abc[A-Z]*2'` ;
Result:#!/usr/bin/perl use strict; use warnings; my $string = "abcABC123ABCabc"; print "Regex1: ", $string =~ /abc[A-Z]*.2/, "\n" ; print "Regex2: ", $string =~ /abc[A-Z]*2/, "\n";
Reason: The first matches any number of uppercase characters, followed by 1 character then followed by a 2 (this regex matched once in the string, therefore 1). The second matches any number of A-Z followed by a 2 - as there is a 1 inbetween, it doesn't match.Regex1: 1 Regex2:
|
|---|