> ## Documentation Index
> Fetch the complete documentation index at: https://loadwise.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# js-fixed-regexp-in-loop

> A stateless RegExp is repeatedly constructed from fixed arguments.

## What it flags

Repeated work constructs a `RegExp` from a fixed string and optional fixed flags and immediately calls `test()` or `exec()`. Loadwise checks patterns up to 1,024 characters against the syntax supported by its Node.js runtime. The finding appears with `--include-contextual`.

## How to review or fix

Measure the allocation cost before reusing the expression. Engines can cache compiled patterns. The rule skips global and sticky expressions because a fresh object resets their `lastIndex`.

## Version compatibility

When rolling back to a Loadwise version released before this rule, remove `js-fixed-regexp-in-loop` from `rules` and `overrides` in `loadwise.config.json` first. Older versions reject rule IDs they do not recognize, including entries set to `off`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.