# prefer-regexp-exec

Rule `typescript/prefer-regexp-exec`. Enforce `RegExp#exec` over `String#match` if no global flag is provided

- Source: typescript
- Technologies: TypeScript
- Kind: style
- Needs type information: yes
- Autofix: yes, in at least one linter
- Reach: 2.2M weekly downloads of presets that enable it
- Trend: +137.0% last quarter
- Rank: #1492 by reach, #85 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `@typescript-eslint/prefer-regexp-exec` | no | safe | package `@typescript-eslint/eslint-plugin` | [docs](https://typescript-eslint.io/rules/prefer-regexp-exec) |
| Oxlint | `typescript/prefer-regexp-exec` | no | no | plugin `typescript`, category style | [docs](https://oxc.rs/docs/guide/usage/linter/rules/typescript/prefer-regexp-exec.html) |
| Biome | `nursery/useRegexpExec` | no | no | group nursery, since 2.3.9 | [docs](https://biomejs.dev/linter/rules/use-regexp-exec/) |

## Code examples

### Incorrect: the rule reports this

```ts
'something'.match(/thing/);

'some things are just things'.match(/thing/);

const text = 'something';
const search = /thing/;
text.match(search);
```

### Correct: the rule accepts this

```ts
/thing/.exec('something');

'some things are just things'.match(/thing/g);

const text = 'something';
const search = /thing/;
search.exec(text);
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
import tseslint from "typescript-eslint";

export default [
  {
    plugins: { "@typescript-eslint": tseslint.plugin },
    rules: {
      "@typescript-eslint/prefer-regexp-exec": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "rules": {
    "typescript/prefer-regexp-exec": "error"
  }
}
```

### Biome: `biome.json`

```json
{
  "linter": {
    "rules": {
      "nursery": {
        "useRegexpExec": "error"
      }
    }
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Ultracite for Oxlint](https://lintradar.dev/presets/ultracite-oxlint.md) | Oxlint | `ultracite` | 475 | 2.1M | +151.7% |
| [eslint-config-love](https://lintradar.dev/presets/love.md) | ESLint | `eslint-config-love` | 258 | 171.7K | +39.3% |

## Related rules

- [unicorn/prefer-regexp-exec](https://lintradar.dev/rules/unicorn/prefer-regexp-exec.md): Prefer `RegExp#exec()` over `String#match()` for non-global regular expressions.
- [sonarjs/prefer-regexp-exec](https://lintradar.dev/rules/sonarjs/prefer-regexp-exec.md): "RegExp.exec()" should be preferred over "String.match()"
- [typescript/no-unsafe-type-assertion](https://lintradar.dev/rules/typescript/no-unsafe-type-assertion.md): Disallow type assertions that narrow a type
- [typescript/default-param-last](https://lintradar.dev/rules/typescript/default-param-last.md): Enforce default parameters to be last
- [typescript/naming-convention](https://lintradar.dev/rules/typescript/naming-convention.md): Enforce naming conventions for everything across a codebase
- [typescript/explicit-member-accessibility](https://lintradar.dev/rules/typescript/explicit-member-accessibility.md): Require explicit accessibility modifiers on class properties and methods

---

Web page: https://lintradar.dev/rules/typescript/prefer-regexp-exec. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
