Strings

interface Strings : Variable

字符串工具接口。 提供丰富的字符串操作、加密、编码转换等功能。 所有方法均为同步执行,且保证方法名不重复(无重载)。

Functions

Link copied to clipboard
abstract fun base64Decode(base64Text: String): String

Base64 解码。

Link copied to clipboard
abstract fun base64Encode(text: String): String

Base64 编码。

Link copied to clipboard
abstract fun concat(text1: String, text2: String): String

拼接两个字符串。

Link copied to clipboard
abstract fun contains(text: String, sub: String): Boolean

判断是否包含子串。

Link copied to clipboard
abstract fun endsWith(text: String, suffix: String): Boolean

判断字符串是否以指定后缀结束。

Link copied to clipboard
abstract fun format(format: String, args: Array<Any>): String

格式化字符串 (类似 Java String.format)。 例如: format("Hello %s", "World") -> "Hello World"

Link copied to clipboard
abstract fun fromBytes(bytes: ByteArray, charsetName: String?): String

将字节数组按指定编码转为字符串。 方法名避免与 Object.toString() 冲突,命名为 fromBytes。

Link copied to clipboard
abstract fun fromHexString(hexText: String): String

Hex (十六进制) 字符串转普通字符串。

Link copied to clipboard
abstract fun getGlobalName(): String

获取作为全局变量时的名称.

Link copied to clipboard
abstract fun getLength(text: String): Int

获取字符串的长度。

Link copied to clipboard
abstract fun getPublicType(): Type

获取 Variable 注入到脚本时需要显示的类型.

Link copied to clipboard
abstract fun indexOf(text: String, sub: String): Int

查找子串第一次出现的索引。

Link copied to clipboard
abstract fun isBlank(text: String): Boolean

判断字符串是否为空白(null, empty, 或只包含空格/制表符)。

Link copied to clipboard
abstract fun isEmpty(text: String): Boolean

判断字符串是否为空(length为0)。

Link copied to clipboard
abstract fun isPrefixRequired(): Boolean

是否需要添加前缀, 每种编程语言添加的前缀不一样, 前缀可以通过 Language.getVariablePrefix 获取.

Link copied to clipboard
abstract fun isSuffixRequired(): Boolean

是否需要添加后缀, 每种编程语言添加的后缀不一样, 后缀可以通过 Language.getVariableSuffix 获取.

Link copied to clipboard
abstract fun lastIndexOf(text: String, sub: String): Int

查找子串最后一次出现的索引。

Link copied to clipboard
abstract fun md5(text: String): String

计算 MD5。

Link copied to clipboard
abstract fun random(length: Int): String

生成指定长度的随机字母数字组合。

Link copied to clipboard
abstract fun replace(text: String, oldString: String, newString: String): String

简单的字符串替换。

Link copied to clipboard
abstract fun replaceRegex(text: String, regex: String, replacement: String): String

使用正则表达式替换。

Link copied to clipboard
abstract fun split(text: String, delimiter: String): List<String>

分割字符串。

Link copied to clipboard
abstract fun startsWith(text: String, prefix: String): Boolean

判断字符串是否以指定前缀开始。

Link copied to clipboard
abstract fun substring(text: String, start: Int, end: Int): String

截取字符串。

Link copied to clipboard
abstract fun toBytes(text: String, charsetName: String?): ByteArray

将字符串按指定编码转为字节数组。

Link copied to clipboard
abstract fun toHexString(text: String): String

字符串转 Hex (十六进制) 字符串。

Link copied to clipboard
abstract fun toLowerCase(text: String): String

转为小写。

Link copied to clipboard
abstract fun toUpperCase(text: String): String

转为大写。

Link copied to clipboard
abstract fun trim(text: String): String

去除两端空格。