Home: Perl Programming Help: Regular Expressions:
blank lines regular expression



devi
Novice

May 10, 2012, 11:49 AM


Views: 16871
blank lines regular expression

i have below lines of code in my tool (cloc--> code count tool) with which it recognizes blank lines

filter remove_matches ^\s*//

but, i want to tell the tool that if a any line contains less than 2 characters then it should consider that line as Blank line. How can modify the above regular expression to consider a line as blank line if it contains less than 2 characters.


FishMonger
Veteran / Moderator

May 10, 2012, 12:01 PM


Views: 16869
Re: [devi] blank lines regular expression

/^.{0,1}$/


(This post was edited by FishMonger on May 10, 2012, 12:01 PM)


rovf
Veteran

Jun 15, 2012, 3:38 AM


Views: 11820
Re: [devi] blank lines regular expression


Code
chomp($line); 
if(length($line)<2) { ignore_this_line() }