Can be seem as a small language for pattern matching
regex101: build, test, and debug regex
A regular expression uses ordinary characters to stand for themselves
a, b, x
→matches the letters itself
RS
→ concatenation of matches of R and S (they are both RegEx)
RS*
→ Single instance of R and 0 or more instances of S
R*
→ 0 or more occurrences of R
.
→ any char but newline
[aeiou]
→ matches chars inside the bracket
[A-Za-z0-9_]
→ matches the range from A-Z, a-z, 0-9 and underscore
[^a]
→ matches any characters except a
[^A-Za-z]
→ matches any characters except A-Za-z
[[:alpha:]]
→ matches any alphabetical characters
^R
→ R that's on the start of the line
R$
→ R that's on the end of the line
\\x
→ just matching the character x
There are other grep algorithms too
for instance, there's the grep -E
(extended grep)