ChOas has asked for the wisdom of the Perl Monks concerning the following question:
Code1:my $String="1234A4321"; my $RegEx="/a/i";
prints: Match: A Pre: 1234 Post: 4321{ $String=~/a/i; print "Match: ",$&||"none"," Pre: ",$`||"none"," Post: ",$'||"none","\ +n"; }
prints:{ $String=~$RegEx; print "Match: ",$&||"none"," Pre: ",$`||"none"," Post: ",$'||"none","\ +n"; } { eval $String=~$RegEx; print "Match: ",$&||"none"," Pre: ",$`||"none"," Post: ",$'||"none"," +\n"; } { eval { $String=~$RegEx; }; print "Match: ",$&||"none"," Pre: ",$`||"none"," Post: ",$'||"none"," +\n"; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Applying a RegEx in a variable
by abstracts (Hermit) on Aug 10, 2001 at 13:51 UTC | |
by ChOas (Curate) on Aug 10, 2001 at 13:59 UTC | |
Re: Applying a RegEx in a variable
by Hofmator (Curate) on Aug 10, 2001 at 14:53 UTC | |
Re: Applying a RegEx in a variable
by George_Sherston (Vicar) on Aug 10, 2001 at 15:37 UTC | |
by Hofmator (Curate) on Aug 10, 2001 at 15:58 UTC | |
by George_Sherston (Vicar) on Aug 10, 2001 at 17:56 UTC | |
by Hofmator (Curate) on Aug 10, 2001 at 18:47 UTC | |
by George_Sherston (Vicar) on Aug 10, 2001 at 19:16 UTC | |
by ChOas (Curate) on Aug 10, 2001 at 16:22 UTC | |
by Hofmator (Curate) on Aug 10, 2001 at 16:37 UTC |