Basic Regular Expression vs Extended Regular Expression

POSIX or "Portable Operating System Interface for Unix" is a collection of standards that define some of the functionality that a UNIX operating system should support. One of these standards defines two flavours of regular expressions. Commands involving regular expressions, such as grep and egrep , implement these flavours on POSIX-compliant UNIX systems.

The only difference between basic and extended regular expressions is in the behaviour of a few special characters: ?, +, parentheses, braces, and |. With basic (BRE) syntax, these characters do not have special meaning unless prefixed with a backslash (\); While with extended (ERE) syntax it is reversed: these characters are special unless they are prefixed with a backslash (\).

grep is BRE which means when we grep 'a+b', it searches for a+b in the text and basically, it doesn't use regular expression for search unless we add a backslash for special characters. BRE is more convenient for hybrid searches so if the user doesn't know the regular expression, they can use the search just as a normal search. if we want to find a+b in ERE, we should use grep -E 'a\+b' because if we don't add a backslash it searches for a string with one or more a and then b.

In Visual Studio Code, because search by regular expression has a separate button to activate, it uses ERE and by default, special characters are control characters.

grep -F finds strings and doesn't use regular expression at all.