# String.search

## 功能

查找字符串或正则表达式在当前字符串中的首次匹配位置。

## 语法

```bt
string.search(pattern)
```

## 参数

| 参数 | 类型 | 必填 | 默认值 | 说明 |
| ------ | ------ | ------ | ------ | ------ |
| pattern | String/Regex | 否 | '' | 要查找的字符串或正则表达式。 |

## 返回值

| 类型 | 说明 |
| ------ | ------ |
| Int | 找到时返回起始字节位置；未找到返回 -1。 |

## 示例

```bt
text = 'hello BT'
result = text.search('BT')

// 输出：6
print result
```

## 注意事项

- 返回值按 UTF-8 字节偏移计算。
