ZGG内置类型-字符串
字符串的声明与访问
// 普通的单行字符串
'asdfadsfdsa'
// ZGG所有字符串都支持多行
'第一行
第二行
第三行'
// 字符串内嵌入标识符和表达式
zgg> name := 'zgg'
zgg
zgg> 'Hello, $name'
Hello, zgg
zgg> 'Hello, ${name.upper()}'
Hello, ZGG
// 如果在字符串开始的单引号前加一个r,表示该字符串内除了\'会转义为'外,其余字符都原样返回,也不会嵌入标识符和表达式。常用于写正则表达式
zgg> r'Hello, \t\'${name.upper()}\''
Hello, \t'${name.upper()}'字符串的运算
加法
乘法
字符串的内置方法
方法名
作用
函数详解
Str.substr(start, end?)
Examples:
Str.upper()
Str.lower()
Str.find(regexp)
Examples:
Str.hash()
Str.split(sp, limit?)
Str.splitr(spRegexp, limit?)
Str.lines()
Str.indexOf(sub, start?)
Examples:
Str.lastIndexOf(sub)
Str.replaceOne(sub, repl)
Examples:
Str.replaceAll(sub, repl)
Examples:
Str.replace(regexp, repl)
Examples:
Str.trim()
Str.startsWith(prefix)
Str.endsWith(suffix)
Str.contains(sub)
Str.decodeHex()
Examples:
Str.decodeBase64()
Str.fillParams(paramsMap)
Examples:
最后更新于