Engine Compatibility
The Node pico engine only accepts an enclosing pound sign.
Regular expressions are enclosed in matching characters with a prepended re
. The conventional character for enclosing a regular expression is a slash (/
), but a pound sign (#
) can be used as well: re/.../
or re#...#
. KRL regular expressions closely follow the conventions for Perl regular expressions. The following modifiers may appear after the closing character:
i
. The i modifier makes the regular expression case insensitive.g
. The g modifier applies the regular expression globally.
For example, the following code replaces the first instance of foo
in p
with bar
:
p.replace(re/foo/, "bar")
In contrast, the following code replaces all instances of foo
in p
with bar
:
p.replace(re/foo/g, "bar")