Logo

Programming-Idioms

History of Idiom 110 > diff from v102 to v103

Edit summary for version 103 by reilas:
[Java] The explanation was incorrectly formatted; the underline doesn't work on \ and +

Version 102

2023-01-25, 12:32:56

Version 103

2023-01-25, 12:39:59

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+");
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.
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.