文字列の右端から、指定した文字数分の文字列を返します。
指定した文字列の最後 (または右端) から、指定した文字数分の文字列を返します。
count 以上の場合は、文字列の右端からの count 文字数分の文字列
count 未満の場合は、文字列全体
count が 1 より大きく、かつ文字列が空の場合は、空の文字列
Right(string, count)
| パラメータ | 説明 |
|---|---|
|
string |
文字列、または文字列を含んでいる変数です。 |
|
count |
返す文字数を指定する正の整数です。 |
<!--- Right の簡単な例--->
<cfoutput>
#Right("See the quick red fox jump over the fence", 9)#
<br>
#Right("ColdFusion", 6)#
</cfoutput>
<!--- フォーム入力を使用した Right の例 --->
<h3>Right の例</h3>
<cfif IsDefined("Form.MyText")>
<!--- len が 0 (ゼロ) を返した場合、エラーメッセージが表示されます。 --->
<cfif Len(FORM.myText)>
<cfif Len(FORM.myText) LTE FORM.RemoveChars>
<cfoutput><p style="color:red; font-weight:bold">文字列
#FORM.myText# には #Len(FORM.myText)# という文字のみが含まれています。この文字列内の
右端からの文字 #FORM.removeChars# は長さが足りないため出力
できません。</p></cfoutput>
<cfelse>
<cfoutput><p>元の文字列 : <strong>#FORM.myText#</strong>
<p>変更後の文字列 (右端からの文字 <strong>#FORM.removeChars#
</strong> のみを表示):
<strong>#right(Form.myText, FORM.removeChars)#</strong></p>
</cfoutput>
</cfif>
<cfelse>
<p style="color:red; font-weight:bold">1 文字以上の文字列を入力
してください。</p>
</cfif>
</cfif>
<form action="<cfoutput>#CGI.ScriptName#</cfoutput>" method="POST">
<p>テキストを入力してください。<br />
<input type="Text" name="myText"></p>
<p>右端から何文字を表示しますか?
<select name="RemoveChars">
<option value="1">1
<option value="3" selected>3
<option value="5">5
<option value="7">7
<option value="9">9</select>
<input type="Submit" name="Submit" value="Remove characters"></p>
</form>
ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX* | ColdFusion 5* | フォーラム* | デベロッパーセンター | サポート情報 | バグ報告
バージョン7