Instantiates a regular expression object
Agent
Name | Type | Description |
---|---|---|
expression | String |
A regular expression
|
A regular expression object
This function compiles a regular expression pattern and returns it as a new regexp2 class instance. The regular expression is limited to 256 characters, and each agent is only allowed to have up to ten regexp2 objects simultaneously.
Below are the codes that may be used to construct the pattern-matching expression. Please note that these may not be the same as the codes available in the standard Squirrel regexp(). They are, however, POSIX compliant syntax.
Code | Operation |
---|---|
\ | Quote the next metacharacter |
^ | Match the beginning of the string |
. | Match any character |
$ | Match the end of the string |
| | Alternation |
(subexp) | Grouping (creates a capture) |
(?:subexp) | No capture grouping (no capture) |
[] | Character class |
* | Match zero or more times |
+ | Match one or more times |
? | Match once or no match |
{n} | Match exactly n times |
{n,} | Match at least n times |
{n,m} | Match at least n times but no more that m times |
\A | At beginning of text |
\b | At word boundary |
\z | At end of text |
\a | Bell (ascii 7) |
\f | Form feed |
\t | Next character is tab |
\n | Next character is newline |
\r | Next character is carriage return |
* | Next character literal * |
\123 | Octal character code (up to three digits |
\x7F | Hex character code (two digits) |
\d | Next character is a digit (0-9) |
\D | Next character is not a digit |
\s | Next character is whitespace |
\S | Next character is not whitespace |
\w | Next character is alphanumeric (a-z, A-Z, 0-9) |
\W | Next character is non-alphanumeric |