grep Extended Regular Expressions (ERE) Tester
Pattern: e.g. (error|warn) , ^[A-Z]+[0-9]+$ , a.*b
Test Text:
grep -E "{Pattern}" uses ERE (Extended Regular Expressions), an extended regular expression syntax used in tools like grep -E. It supports richer matching features such as +, |, () and {}, making it more concise and readable compared to basic regular expressions.
CategorySyntax / ExampleDescription
Any Character.Matches any single character (except newline)
Repetition (0+)a*Matches zero or more occurrences of "a"
Repetition (1+)a+Matches one or more occurrences of "a"
Optionala?Matches zero or one occurrence of "a"
Range Repetitiona{2,5}Matches between 2 and 5 occurrences of "a"
Exact Repetitiona{3}Matches exactly 3 occurrences of "a"
Grouping(abc)+Treats "abc" as a group and repeats it
Alternation (OR)a|bMatches either "a" or "b"
Start Anchor^abcMatches content starting with "abc"
End Anchorabc$Matches content ending with "abc"
Character Class[abc]Matches any one of "a", "b", or "c"
Negated Class[^abc]Matches any character except "a", "b", or "c"
Range[a-z]Matches characters within a range
POSIX Character Class[[:digit:]]Matches digits (recommended for portability)
Combined Class[[:alnum:]_]Matches letters, digits, or underscore
Escape Character\.Escapes special characters (e.g., match literal ".")
ConcatenationabcMatches "abc" in sequence
Greedy Matcha.*bMatches as much as possible between "a" and "b"
Nested Pattern(ab|cd)+Matches repeated sequences of "ab" or "cd"
Complex Example^[a-zA-Z0-9_]+$Matches strings containing only letters, digits, or underscore
Note* + ? are greedyNon-greedy quantifiers (like *?) are not supported
NoteNo support for \d \wUse POSIX classes instead (e.g., [[:digit:]])
Note() for groupingParentheses do not require escaping in ERE