# no-regex-spaces

> Disallow several spaces in a row in a regular expression

In `/error   code/` you can't tell at a glance whether there are two, three or four spaces. ` {3}` spells it out.

The rule checks regular expression literals and strings passed to `RegExp`. Spaces inside a character class such as `[  ]` aren't reported.

`--fix` replaces the spaces with one space and a count.

This rule is on by default.

{/* Generated by src/codegen/lint-rule-docs.ts. Do not edit this section. */}

## Configure

On by default as a warning. To turn it off:

```toml bunfig.toml
[lint.rules]
"no-regex-spaces" = "off" # or "error"
```

{/* End of the generated section. */}

## Examples

Reported:

{/* bad {"count": 2} */}
```js
const line = /error   code/;
const header = new RegExp("name  value");
```

Not reported:

{/* good */}
```js
const line = /error {3}code/;
const header = new RegExp("name {2}value");
const anyGap = /name +value/;
```
