cwal

s2 JavaScript-style Regexes
Login

s2 JavaScript-style Regexes

(⬑Main Module Docs)

JavaScript-style Regular Expressions


ACHTUNG (2020-03-01): since this plugin was written, numerous regex bugs have been discovered in the upstream JS-regex library upon which it is based. In short, its results currently cannot be trusted:

https://github.com/ccxvii/mujs/issues/130


This library has two distinct regular expression modules with nearly-identical APIs: the common features are described in the POSIX regex module docs and this page describes only those features peculiar to this flavor.

This module, ported in from Tor Andersson's MuJS project, provides support for JavaScript-style regular expressions, noting that only the pattern syntax is JS-like, not the API of the compiled RegExp objects. e.g. these cannot (unlike in JS) be used to iterate over a string looking for multiple matches. (That said, the first time i desperately want/need such a feature, something approximating it will be added!)

JS-flavor Compilation Flags

See also: POSIX compilation flags

Regex compilation may be modified by providing a string of single-letter flags. Unknown flags cause an exception to be thrown. The flags for this module are listed below. The upper-case names listed next to each flag are the C-level names for the flags.

JS-flavor Match-time Flags

See also: POSIX match-time flags

Like compilation flags, flags which change regex matching behaviour at match-time may be provided as a string of letters describing the flag(s):