AI-assisted disclosure: This article was prepared with AI assistance. Every JavaScript example was executed with the companion Node.js validation script; no human editorial review was used.

A regular expression can be correct in isolation and still fail in an application. The failure may come from a flag, a Unicode representation, the API used to consume the expression, or the mutable state of a shared RegExp object.

That is why “try another pattern” is often a poor debugging strategy. A better approach is to turn the bug into a small test matrix.

The matrix has four useful axes:

Axis