This language bar is your friend. Select your favorite languages!

Idiom #110 Check if string is blank

Set boolean blank to true if string s is empty, or null, or contains only whitespace ; false otherwise.

blank := trim(s) = '';
with Ada.Strings.Fixed;
use Ada.Strings.Fixed;
Blank := Index_Non_Blank (Str) = 0;
import std.algorithm;
import std.uni;
bool blank = s.all!isSpace;
blank = s == nil || String.length(String.trim s) == 0
import "strings"
blank := strings.TrimSpace(s) == ""
import Data.Char (isSpace)
blank :: Bool
blank = all isSpace s
import Data.Char (isSpace)
b = null (dropWhile isSpace s)
let blank = s == null || !s.test (/[^\s]/)
import org.apache.commons.lang.StringUtils;
boolean blank = StringUtils.isBlank(s);
boolean blank = s.trim().isEmpty();
blank = s ~= nil and s:match("%S") ~= nil
$blank = !trim($s);
$blank = (empty(trim($s));
$blank = !$s || $s=~/^\s*$/;
blank = s is None or s == '' or s.isspace()
blank = s.strip.empty?
let blank = s.trim().is_empty();
val blank = s.trim().isEmpty()

Do you know the best way to do this in your language ?
New implementation...

Idiom created by

programming-idioms.org