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?

$Translate 関数と $Replace 関数

$Translate 関数は文字列の中の 1 つ以上の文字を、異なる文字に置換します。また、文字列から文字を削除します。lookup ルーチンでは、小文字を大文字に、あるいは大文字を小文字に置換します。

記述した mydatent ルーチンの name プロンプトは、“Agee,Tommie” の大文字/小文字を区別します。$Translate を使用すると、ユーザが入力した名前文字列の大文字/小文字を区別しません (例 : “a” あるいは “AGEE”)。

$Replace 関数は $Translate 関数と似ていますが、$Replace の場合 2 番目と 3 番目の引数が文字のリストではなく完全な文字列として扱われます。

SAMPLES>write $translate( "abcde", "ad", "yz" ) ; translate a->y, and d->z
ybcze
SAMPLES>write $translate( "abcde", "ad", "zz" ) ; translate a->z, and d->z
zbcze
SAMPLES>write $translate( "abcde", "ad", "z") ; translate a->z, and d->nothing
zbce
SAMPLES>write $translate( "abcdebcbc", "abc", "yz" ) ; translate a->y, b->z, and c->nothing
yzdezz
SAMPLES>write $replace( "abcdebcbc", "abc", "yz" ) ; replace abc->yz
yzdebcbc
SAMPLES>read "String to translate: ", x

SAMPLES>set lower = "abcdefghijklmnopqrstuvwxyz"

SAMPLES>set upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

SAMPLES>write !, $translate( x, lower,  upper )
String to translate: the quick brown fox jumps over the lazy dog
THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG
SAMPLES>
FeedbackOpens in a new tab