Skip to content
Flavor
ECMAScript
Deadline
500 ms
Runtime
Browser

Keep or remove lines that match a regular expression

Apply one pattern independently to each line and choose whether matching or nonmatching lines survive.

Local processingNo sign-upKillable worker

Input

Choose keep or remove; output line endings are normalized to LF.

Local

Use i for case-insensitive filtering and m only when its anchor behavior is intentional.

Filtered lines

Submit the example or replace it with your own values. User matching runs only in a disposable browser worker.

What this tool proves

Explicit ECMAScript behavior

Line filtering resets RegExp.lastIndex before each line. That prevents a global pattern's state from leaking between lines while preserving sticky matching at line offset zero when y is selected.

Each line is an independent match decision

Line filtering resets RegExp.lastIndex before each line. That prevents a global pattern's state from leaking between lines while preserving sticky matching at line offset zero when y is selected.

CRLF, CR, LF, line separator, and paragraph separator are recognized as input boundaries. Returned lines use LF consistently, and a hard 20,000-line guard runs before user matching begins.

Bounded execution protects the page without hiding risk

Any operation that runs a user pattern is isolated in a disposable Web Worker. Tool Swim terminates that worker after 500 ms, caps patterns at 4 KiB and text at 256 KiB, and never runs user matching on the interface thread.

Pattern, flags, text, replacement, matches, and explanations stay in the current browser tab. The public tool makes no developer API request, stores no preset, and works without an account or telemetry.

Primary references

Questions and answers

Related Regex tools