Anvil | Smiths Smiths | Register Register | Login Login |
Search:
Show links Show tools Show tree | Previous document Next document | njet.org > Anvil > Documentation > Language reference > Lexical analysis > Literals > Regular expressions

Regular expression

Anvil supports regular expressions compatible with Perl 5. A regular expression starts and ends with a slash (/) but must remain on the same line, as line feeds cannot be contained. A backlash may be used to escape some critical characters inside an expression, such as a slash (/), a backlash (\), and an open bracket ([); other than that, there is no similar quotation mechanism as in strings.

Immediately after the expression, there may a set of flags:
FlagsMeaning
i or I Performs case insensitive matching.
m or M Treats string as multiple lines. That is, change "^" and "$" from matching the start or end of the string to matching the start or end of any line anywhere within the string.
x or X Extends the pattern's legibility by permitting whitespace.

Examples:
  p = /[a-z]+/i;
  q = /\/[0-9]+\//;
See also  | Literals  | Constants  | Pattern matching  | Grammar
Contributes notes:
Add a note
What's new | Anvil