Text Processingflags: gm

Trailing Whitespace (Per Line)

Match trailing spaces and tabs at the end of each line — the regex linters use to flag dirty whitespace.

Try it in RegexPro →

Available in

Pattern

regexengine-agnostic
[ \t]+$   (flags: gm)

Raw source: [ \t]+$

How it works

[ \t]+ matches one or more space or tab characters. $ with the m (multiline) flag anchors to the end of EACH line, not the whole string. The g flag iterates so a multi-line string surfaces every offending line. Pair with `replace(re, '')` to strip.

Examples

Input

good line\nbad line \nfine

Matches

Input

tab here\tand more\t\t

Matches

  • \t\t

Input

no trailing space

No match

Common use cases

  • Linter / formatter rules (eslint, prettier, gofmt)
  • Pre-commit hooks for cleanup
  • Markdown source hygiene
  • Git diff noise reduction