# Regex regular expression ## Function Regex objects are created by regex(pattern, flags) and support test, match, replace and to_string. String prototype search, match, replace can also receive Regex parameters. ## API List | API | Description | | ------ | ------ | | [Regex.test](/en/docs/regex/test) | Determine whether the text matches the current regular expression. | | [Regex.match](/en/docs/regex/match) | Returns all matching fragments in the text. | | [Regex.replace](/en/docs/regex/replace) | Replace text using the current regular expression. | | [Regex.to_string](/en/docs/regex/to_string) | Returns the script text form of the regular expression. | ## Examples ```bt rule = regex('BT', 'i') result = rule.test('bt lang') // Output: true print result ``` ## Notes - Supported flags include i, m, s; the global replacement of replace additionally reads the g flag.