String.contain
String.contain
功能
判断字符串是否包含指定片段。
语法
string.contain(needle)
参数
| 参数 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
| needle | Any | 否 | '' | 要查找的片段,调用时会先转为字符串。 |
返回值
| 类型 | 说明 |
|---|---|
| Bool | 包含时返回 true,否则返回 false。 |
示例
text = 'hello BT' result = text.contain('BT') // 输出:true echo(result)
注意事项
- 匹配区分大小写。
- 未传参数时按空字符串查找,返回 true。