1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

SFDC:String.isEmptyとString.isBlankの違い

Posted at

isBlank(inputString)
指定した string が空白、空 ('')、または null の場合は true、それ以外の場合は false を返します。
isEmpty(inputString)
指定した string が空 ('') または null の場合は true、それ以外の場合は false を返します。

Open Execute Anonymous Windowで検証しました。

String key = null; // null
System.debug('isEmpty(null) = ' + String.isEmpty(key));
System.debug('isBlank(null) = ' + String.isBlank(key));

key = ''; // 空
System.debug('isEmpty(空) = ' + String.isEmpty(key));
System.debug('isBlank(空) = ' + String.isBlank(key));

key = ' '; // 半角空白
System.debug('isEmpty(半角空白) = ' + String.isEmpty(key));
System.debug('isBlank(半角空白) = ' + String.isBlank(key));

key = ' '; // 全角空白
System.debug('isEmpty(全角空白) = ' + String.isEmpty(key));
System.debug('isBlank(全角空白) = ' + String.isBlank(key));

key = '  '; // 半角全角混在空白
System.debug('isEmpty(半角全角混在空白) = ' + String.isEmpty(key));
System.debug('isBlank(半角全角混在空白) = ' + String.isBlank(key));

キャプチャ.PNG
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?