Skip to main content
2 of 2
Formatting.
Stephen Kitt
  • 481k
  • 59
  • 1.2k
  • 1.4k

Grep options for Regular Expressions. (ERE, BRE, Perl regex) differences

I am getting the hang of grep and regex, but I am confused about the different options.

grep --help | grep -i "reg.*ex"
  -E, --extended-regexp     PATTERN is an extended regular expression (ERE)
  -G, --basic-regexp        PATTERN is a basic regular expression (BRE)
  -P, --perl-regexp         PATTERN is a Perl regular expression

I have a general knowledge of regular expressions, but often I find myself stumbling on the basics (e.g. Using '*' when it actually requires '.*'), which I blame on not knowing the differences between the types of regular expressions (ERE, BRE, Perl regex).

Is it explained somewhere in detail?