Regex4 - Subexpressions

Alternatives are defined with the binary OR metacharacter, the pipe |

This will find either bob or sam:

egrep 'bob|sam' text.txt

Subexpressions can be defined with parenthesis metacharacters to limit scope

This will find submarine and subclipse:

egrep 'sub(marine|clipse)' test.txt

Tags: regex