go ahead... be a heretic | |
PerlMonks |
Re: Need advice on PERLby kabeldag (Hermit) |
on Dec 12, 2006 at 08:59 UTC ( [id://589235]=note: print w/replies, xml ) | Need Help?? |
- ^ is match at beginning .. - \d is looking for a digit character - + is find \d 1 or more times - (...) Groups subexpressions for capturing to $1, $2,$3 ... In this case, $scrip will return the the complete sub expression match (which is inside the brackets : (\d+\.\d+\.\d+\.\d+) ): INPUT C:\Perl\bin>perl bleh.pl 1.0.3.3_1.3.45.44 OUTPUT $scrip returned : 1.0.3.3 match 1 : 1.0.3.3 match 2 : match 3 : match 4 : If "\d+\.\d+\.\d+\.\d+" wasn't inside the brackets, $scrip would return 1, if it matched the reg-ex: OUTPUT EXAMPLES: C:\Perl\bin>perl bleh.pl 13.3.3.3_ matched 13.3.3.3_ ! $scrip = 1 C:\Perl\bin>perl bleh.pl 13.3. did not match 13.3. ! $scrip =
In Section
Seekers of Perl Wisdom
|
|