Logo

Programming-Idioms

  • Go

Idiom #110 Check if string is blank

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

import "strings"
blank := strings.TrimSpace(s) == ""

Trim s, then check if empty.
with Ada.Strings.Fixed;
use Ada.Strings.Fixed;
Blank := Index_Non_Blank (Str) = 0;

New implementation...