> For AI agents: the complete documentation index is available at https://rslint.rs/llms.txt, the full documentation bundle is available at https://rslint.rs/llms-full.txt.

# prefer-regexp-exec

[Added in v0.3.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.3.0)
## Configuration

| Preset                            | Configured Value |
| --------------------------------- | ---------------- |
| ✅ ts.configs.stylisticTypeChecked | `"error"`        |


```ts title=rslint.config.ts
import { defineConfig, ts } from '@rslint/core';

export default defineConfig([
  ts.configs.recommended,
  {
    rules: {
      '@typescript-eslint/prefer-regexp-exec': 'error',
    },
  },
]);
```

## Rule Details

Prefer `RegExp#exec` over `String#match` when a non-global regex match is used.

Examples of **incorrect** code for this rule:

```ts
const value = 'foo';
value.match(/foo/);
value.match('foo');
```

Examples of **correct** code:

```ts
const value = 'foo';
/foo/.exec(value);
value.match(/foo/g);
```

## Original Documentation

- [typescript-eslint: prefer-regexp-exec](https://typescript-eslint.io/rules/prefer-regexp-exec)
- [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/prefer-regexp-exec.ts)
