regular expression cheatsheet

Preface

Some useful tips for regular expressions Source:

BRE & ERE

  1. BRE: basic regular expression
  2. ERE: extended regular expression
  3. PCRE: Perl compatible regular expression

features added by each flavor of regex:
ERE : + ? | ( ) { } as metacharacter by default, need to be escaped in BRE
PCRE : \d, \w, etc

BRE -> grep, sed
ERE -> grep -E, sed -r, awk
PCRE -> grep -P