# regex ## Function Compiles a regular expression and returns a Regex object. ## Syntax ```bt regex(pattern, flags) ``` ## Parameters | Parameters | Type | Required | Default value | Description | | ------ | ------ | ------ | ------ | ------ | | pattern | String | No | '' | Regular expression text. | | flags | String | No | '' | Flag; i ignores case, m is multi-line, s matches newline with dot, and g is used for global replacement by replace. | ## Return value | Type | Description | | ------ | ------ | | Regex | Returns a regular object that can call test, match, and replace. | ## Example ```bt rule = regex('BT', 'i') result = rule.test('bt') // Output: true print result ``` ## Notes - A Chinese error is thrown when regular compilation fails.