Instantiates a regular expression object
Device + Agent
Name | Type | Description |
---|---|---|
expression | String |
A regular expression
|
Regular expression object
This function compiles a regular expression pattern and returns it as a new regexp object.
Important Because of shortcomings in Squirrel’s regexp, we strongly recommend that you implement regular expressions in your agent code using regexp2() as a drop-in replacement for regexp().
Below are the codes that may be used to construct the pattern-matching expression.
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 |
\l | Next character is lower case |
\u | Next character is upper case |
\a | Next character is a letter (a-z, A-Z) |
\A | Next character is not a letter |
\w | Next character is alphanumeric (a-z, A-Z, 0-9) |
\W | Next character is non-alphanumeric |
\s | Next character is a space |
\S | Next character is not a space |
\d | Next character is a digit (0-9) |
\D | Next character is not a digit |
\x | Next character is a hexadecimal digit (0-F) |
\X | Next character is not a hexadeximal digit |
\c | Next character is a control character |
\C | Next character is not a control character |
\p | Next character is a punctuation mark |
\P | Next character is not a punctuation mark |
\b | Match a character on a word boundary |
\B | Match a character not a word boundary |
\t | Match a tab character |
\n | Match a newline (NL) or linefeed (LF) character |
\r | Match a carriage return (CR) character |
\f | Match a formfeed (FF) character |