Steffan Harris Steffan Harris - 4 months ago 7
Perl Question

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

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

Answer
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
}