Tab Character
Match literal tab characters — the regex behind every formatter / linter that yells about indentation.
Try it in RegexPro →Available in
JavaScript / ECMAScript code
const re = new RegExp("\\t", "g");
const input = " spaces\\there";
const matches = [...input.matchAll(re)];
console.log(matches.map(m => m[0]));Uses `String.prototype.matchAll` for global iteration (Node 12+ / all modern browsers).
Python (re) code
import re
pattern = re.compile(r"\t")
input_text = " spaces\there"
for m in pattern.finditer(input_text):
print(m.group(0))Stdlib `re` module — no third-party dependency. Works on Python 3.6+.
Go (RE2) code
package main
import (
"fmt"
"regexp"
)
func main() {
re := regexp.MustCompile(`\t`)
input := ` spaces\there`
for _, match := range re.FindAllString(input, -1) {
fmt.Println(match)
}
}Uses `regexp.MustCompile` (panics on bad patterns at startup) and `FindAllString` for all matches.
Pattern
\t (flags: g)Raw source: \t
How it works
Examples
Input
spaces\thereMatches
\t
Input
\t\tdouble tabMatches
\t\t
Input
no tabs at allNo match
—Common use cases
- •Tabs-to-spaces conversion in linters
- •Mixed-indentation detection
- •TSV / log parsing
- •Code-formatter diagnostic rules
Related patterns
Non-ASCII Character
Text ProcessingMatch runs of non-ASCII characters (anything outside U+0000–U+007F).
Hashtag
Text ProcessingMatch hashtags (# followed by word characters) in social media posts, including accented Latin characters.
Base64 String
Text ProcessingMatch Base64-encoded strings, including proper padding with = and == characters.
Emoji (Unicode)
Text ProcessingMatch emoji characters across the main Unicode emoji ranges — requires the Unicode flag in JavaScript.