-
Notifications
You must be signed in to change notification settings - Fork 0
API Regex
Liu.Yandong.Hanks edited this page Aug 21, 2026
·
3 revisions
Reusable regular-expression value.
Regex creates a compiled, reusable regular expression. Pass an instance to text.match, text.matchAll, or text.replace, or call test when only a Boolean answer is needed.
Creating the regex once outside a loop avoids repeating the pattern work on every iteration.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
pattern |
string or Regex
|
Yes | Pattern text, or an existing Regex. |
flags |
string |
No | Flag string, such as i for case-insensitive or g for global. |
Returns
Regex — the regular expression.
Behavior
Passing an existing Regex without flags returns that same instance unchanged.
Important
text.matchAll needs a global regex. Include the g flag when you want every match rather than the first.
Example
var number = new Regex("^[0-9]+$");
return number.test("42"); // trueParameters
| Name | Type | Required | Description |
|---|---|---|---|
value |
string |
Yes | Text to test. |
Returns
boolean — whether the regex matches the input text.
Example
var word = new Regex("aurora", "i");
return word.test("AuroraScript"); // trueAuroraScript.JIT 4.0.0 · Documentation Home · Repository · MIT License