Regex and Fixed Strings/Match one of several patterns

Search for either of two words.

Section: Regex basics

Match one of several patterns

bash
bash
rg 'warn|error' logs/
Explanation

Alternation is often the fastest way to combine related searches into one pass.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Regex basics
Match whole words only
Avoid partial matches inside larger identifiers.
OpenIn sheetbashsame section
Match numeric fragments
Find three-digit numeric sequences.
OpenIn sheetbashsame section
Use capture groups in patterns
Group pieces of a regex for readability or PCRE2 replacements.
OpenIn sheetbashsame section
Show non-matching lines
Return the lines that do not match the pattern.
OpenIn sheetbashsame section
Escape regex metacharacters
Search for a literal dot while staying in regex mode.
OpenIn sheetbash2 tag match
Use Unicode-aware classes
Search for letters with Unicode-aware semantics.
OpenIn sheetbash2 tag match