JS-Interpreter RegExp Demo

Pathological regular expressions can execute in geometric time. For example 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac'.match(/^(a+)+b/) will effectively crash any JavaScript runtime. JS-Interpreter has three modes for handling regular expressions.

REGEXP_MODE = 0

In mode 0, all regular expressions are disabled and throw an error. This is safe and works in every environment.


REGEXP_MODE = 1

In mode 1, all regular expressions are executed natively. This is potentially unsafe and works in every environment.


REGEXP_MODE = 2 (default mode)

In mode 2, all regular expressions are executed in a separate environment. In web browsers this means asynchronously in a Web Worker thread, in Node.js this means synchronously in a VM. If a regular expression takes more than REGEXP_THREAD_TIMEOUT (default 1000 ms) then it is terminated and an error thrown. This is safe and works in most environments. If Web Workers or VM is not supported (meaning IE 9 or IE 10), then all regular expressions throw an error.


Back to the JS-Interpreter documentation.