Regular Expression Literals
March 24, 2026 ยท View on GitHub
You can create a regular expression literal in brighterscript. This simplifies pattern writing and improves readability. You can use these regular expression literals anywhere you would normally use CreateObject("roRegex", "the-pattern", "g").
Example:
print /hello world/ig
transpiles to:
print CreateObject("roRegex", "hello world", "ig")
Considerations
Escape the forward slash character
Since the forward slash character (/) indicates the start and end of the expression, you must escape it with a backslash.
Example:
print /hello\/world/
transpiles to
print CreateObject("roRegex", "hello\/world", "")