Logo

Programming-Idioms

History of Idiom 110 > diff from v61 to v62

Edit summary for version 62 by sss:
[Lua] sss

Version 61

2021-02-26, 08:59:12

Version 62

2021-03-03, 05:08:19

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
Comments bubble
%S is the pattern for "not a space"
Comments bubble
%S is the pattern for "not a space"
Demo URL
http://codepad.org/uOOuuNQ6
Demo URL
http://codepad.org/uOOuuNQ6