Logo

Programming-Idioms

History of Idiom 110 > diff from v101 to v102

Edit summary for version 102 by reilas:
New Java implementation by user [reilas]

Version 101

2022-12-01, 10:36:53

Version 102

2023-01-25, 12:32:56

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.

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.

Code
boolean blank = s == null || s.equals("") || s.matches("\\s+");
Comments bubble
The regular expression token _\s will match a space and any of the following escape-sequences: \r \n \t \f \v.

The _+ will match one or more _\s.