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?

文字列関数 (1)

ObjectScript は、文字列を操作するための関数を提供しています。ここでは、よく利用される関数をいくつか紹介します。

  • $Length は文字列の長さを返します。

  • $Extract は、開始位置と終了位置から部分文字列を返します。最後の文字位置を表すアスタリスク (*) や、最後から n 番目の文字位置を表す *-n を使用できます。

  • $Find は、文字列内の部分文字列を検索し、部分文字列の 次の 文字位置を返します。

  • $Piece は、区切り記号を使用して文字列を区分けし、部分文字列を返します。

  • $Justify は、指定された長さの文字列を右揃えして返し、小数点の丸め位置も指定します。

SAMPLES>write $length("how long is this?")
17
SAMPLES>write $extract("there's gold in them hills", 9, 12)
gold
SAMPLES>write $extract("there's gold in them hills", *-4, *)
hills
SAMPLES>write $find("there's gold in them hills", "gold")
13
SAMPLES>write $piece("slice of pizza", " ", 3)
pizza
SAMPLES>write $justify(3.1415, 10, 3)
     3.142
SAMPLES>

各関数は他の書式でも記述できます。詳細は Caché ドキュメントを参照してください。

FeedbackOpens in a new tab