engines

The same pattern can mean different things in different tools That is not a bug, it is a dialect

BRE

Basic regular expressions + , ? , { , } are literals unless escaped grep without flags uses BRE

ERE

Extended regular expressions + , ? , { , } are special grep -E and sed -E use ERE

PCRE

Perl compatible regular expressions \d , \w , lookarounds , named groups grep -P uses PCRE where available

Practical rule

Write for the engine you control If the script must run on busybox, macOS, and GNU Linux, test all three A pattern that is correct on one and silent on another is worse than a slow one

End

Regex is a tool, not a language Keep the pattern small enough to read aloud If it needs a comment longer than the line, rewrite it

Posted