# String.match ## Function Returns a string or regular expression match result. ## Syntax ```bt string.match(pattern) ``` ## Parameters | Parameters | Type | Required | Default value | Description | | ------ | ------ | ------ | ------ | ------ | | pattern | String/Regex | No | '' | The string or regular expression to match. | ## Return value | Type | Description | | ------ | ------ | | Array/Empty | If string pattern matching is successful, an array containing needle will be returned; if the regular pattern does not have the g flag, a capture group array will be returned; if the regular pattern has the g flag, all matching text will be returned; if there is no match, Empty will be returned. | ## Example ```bt text = 'hello BT' result = text.match('BT') // Output: ["BT"] print result ``` ## Notes - When there is no g flag in the regular expression, the 0th item is a complete match, and subsequent items are capturing groups; the missing capturing group is Null.