Regular expressions (regex) basics
Sign in to read this lesson
Regex lets you search text for a pattern rather than a fixed word: "a line starting with a digit", "an IP address", "a name ending in .conf". grep, sed and awk all speak the same language, so you only need to learn it once.
What you will learn
^is the start of a line,$the end:^#is a line starting with#,^$an empty line..is any single character,the previous character 0 or more times,.means "anything".[abc]is one character from the list,[0-9]a digit,[^0-9]a non-digit.- With
grep -E,+(1 or more),?(0 or 1),{n}(n times),|(or) and( )grouping work. - To search for a special character literally, put
\in front:\.is the dot itself.
The lesson has 5 key points, an explanation and 5 questions. It opens with a package.