RIGHT
来源: https://www.freebasic.net/wiki/wikka.php?wakka=KeyPgRight 最后更新: 2020-09-12
返回字符串最右侧的子字符串。
语法
declare function Right ( byref str as const string, byval n as integer ) as string
declare function Right ( byref str as const wstring, byval n as integer ) as wstring用法:
result = Right[$]( str, n )参数
- str — 源字符串。
- n — 子字符串的长度(以字符为单位)。
返回值
返回 str 最右侧的子字符串。
说明
返回从 str 右端(末尾)开始的最右侧 n 个字符。
- 如果
str为空,返回""。 - 如果
n <= 0,返回""。 - 如果
n > Len(str),返回整个源字符串。
示例
vb
Dim text As String = "hello world"
Print Right(text, 5)输出:
worldUnicode 示例:
vb
Dim text As WString * 20
text = "Привет, мир!"
Print Right(text, 5) 'displays " мир!"平台差异
- DOS 不支持
Right的宽字符串版本。
方言差异
- 在
-lang qb方言中需要字符串类型后缀$。 - 在
-lang fblite方言中字符串类型后缀$是可选的。 - 在
-lang fb方言中字符串类型后缀$被忽略。
与QB的区别
- QB 不支持 Unicode。