Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to test to see if a string is only whitespace in perl

Tags:

regex

perl

Whats a good way to test to see if a string is only full of whitespace characters with regex?

like image 931
Steffan Harris Avatar asked May 24 '11 04:05

Steffan Harris


1 Answers

if($string=~/^\s*$/){
    #is 100% whitespace (remember 100% of the empty string is also whitespace)
    #use /^\s+$/ if you want to exclude the empty string
}
like image 166
tobyodavies Avatar answered Oct 24 '22 22:10

tobyodavies