Skip to main content

This is documentation for Caché & Ensemble. See the InterSystems IRIS version of this content.Opens in a new tab

For information on migrating to InterSystems IRISOpens in a new tab, see Why Migrate to InterSystems IRIS?

Len

変数の格納に必要な文字列の文字数、あるいはバイト数を返します。

Synopsis

Len(string | varname [,delimiter])

引数

string 有効な文字列式。
varname 任意の有効な変数名。
delimiter オプション — ターゲット文字列内の部分文字列の境界を示す有効な文字列式。delimiter が指定されていても、文字列に含まれていない場合、Len 関数は 1 を返します。

概要

Len 関数は指定した文字列内または指定した変数内の値の文字数を返します。数値は、先頭と末尾のゼロやプラス記号が削除され、キャノニック形式に変換されます。空の文字列 ("") の場合、0 の文字列長が返されます。未定義の変数の場合も、0 の文字列長が返されます。

以下の例では、Len 関数を使用して文字列内の文字数を返します。

Println Len("InterSystems")  ' Returns 12
Println Len(+0099.900)        ' Returns 4
Println Len("0099.900")      ' Returns 8
Println Len("")              ' Returns 0

以下の例では、Len 関数を使用して、変数の格納に必要なバイト数を返します。

x = 0099.900
y = Now
Println Len(x)        ' Returns 4
Println Len(y)        ' Returns 21:
                      ' mm/dd/yyyy 00:00:00PM
Println Len(z)        ' Returns 0

以下の例では、Len 関数を使用して、文字列内で "/" 文字によって区切られている部分文字列の数を返します。

Dim MyPieces
MyPieces = Len("09/02/1994", "/") 'MyPieces contains 3
Println MyPieces," pieces of the string"

関連項目

FeedbackOpens in a new tab