← All pipes
Text

escapeRegExp

Turn a search term into literal regex pattern text.

Use it in your component

Standalone component
import { Component } from '@angular/core';
import { EscapeRegExpPipe } from 'extra-pipe';

@Component({
  standalone: true,
  imports: [EscapeRegExpPipe],
  template: `{{ "a+b?" | escapeRegExp }}`,
})
export class ExampleComponent {

}

Template
{{ "a+b?" | escapeRegExp }}

Try it live.

The output below runs the packed library. Edit data, not code.

Use double quotes for text, or a number, array, object or null.
No parameters: use []. Locale is controlled separately.
This pipe has no locale override.
Live template data
readonly value = "a+b?";

{{ value | escapeRegExp }}

Rendered output

a\+b\?