Regex

Regular expressions are represented by the Regex class, which is usually created with a literal:

foo_or_bar = /foo|bar/
heeello    = /h(e+)llo/
integer    = /\d+/

A regular expression literal is delimited by / and uses PCRE syntax.

It can be followed by these modifiers:

  • i: ignore case (PCRE_CASELESS)
  • m: multiline (PCRE_MULTILINE)
  • x: extended (PCRE_EXTENDED)

For example

r = /foo/imx

Slashes must be escaped:

slash = /\//

An alternative syntax is provided:

r = %r(regex with slash: /)

results matching ""

    No results matching ""