Logo

Programming-Idioms

History of Idiom 110 > diff from v20 to v21

Edit summary for version 21 by :
[Lua] explain the pattern

Version 20

2016-04-07, 08:05:48

Version 21

2016-04-07, 08:06:43

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.

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.

Code
blank = s ~= nil and s:match("%S") ~= nil
Code
blank = s ~= nil and s:match("%S") ~= nil
Comments bubble
%S is the pattern for "not a space"
Demo URL
http://codepad.org/uOOuuNQ6
Demo URL
http://codepad.org/uOOuuNQ6