|
Prev: Running system commands
Next: unicode
From: Davy on 20 Jun 2006 07:14 Hi, Is ^$ mean a NULL line? Best regards, Davy
From: Mirco Wahab on 20 Jun 2006 07:25 Thus spoke Davy (on 2006-06-20 13:14): > Is ^$ mean a NULL line? No, its usually used for detection of "lines with no characters in them" (only the logical line feed \n is there) in /m mode of a regex. Regards Mirco
From: Mirco Wahab on 20 Jun 2006 07:35 Thus spoke Mirco Wahab (on 2006-06-20 13:25): > "lines with no characters in them" A made up example of how you would use it: use strict; use warnings; my $count = 0; my $text= <<END_OF_TEXT; A Line with something in it two empty lines above! (done) END_OF_TEXT print "empty line " . ++$count . " found\n" for $text =~ /^$/gm; # <== here we go Regards Mirco
From: Nick of course on 20 Jun 2006 08:53 Mirco Wahab wrote: > Thus spoke Mirco Wahab (on 2006-06-20 13:25): > > > "lines with no characters in them" > > A made up example of how you would use it: > > > use strict; > use warnings; > > my $count = 0; > my $text= <<END_OF_TEXT; > A Line with something in it > > > two empty lines above! > (done) > END_OF_TEXT > > print "empty line " . ++$count . " found\n" > for $text =~ /^$/gm; # <== here we go > > > > Regards > > Mirco A slightly shorter answer to the original question would have been "Yes"
From: Dr.Ruud on 20 Jun 2006 08:55
Davy schreef: > Is ^$ mean a NULL line? Nice riddle! Can I ask yes/no-questions? If yes: Is you read the posting guidelines? Show us the effective code that uses that "^$". Where does it fail? If you want to learn to use regular expressions, read perlre and friends. -- Affijn, Ruud "Gewoon is een tijger." |