Basics Flashcards
Basic elements of regex
Indicates the start of the expression
Indicates the end of the expression
$
lowercase characters
[[:lower:]]
alphabetical characters
[[:alpha:]]
Numbers
[[:digits:]]
Punctuation
[[:punct:]]
Uppercase
[[:upper:]]
Wildcard for 1 character
.
Escape character
\
So when you need to search for a period, you’d enter .
Wildcard for multiple charcters
*
Check for a specific number of characters
{2n}\ for example ‘T.{2}n’
Back references
grep ‘(.)(\1)’ this finds any scenario where there are two identical charcters, side by side
What is a token
Symbol character that has a specific meaning, rather than purely it’s face value
What is a character class
A way to check for a specific set of characters
whitespace
[[:space:]]
What happens if grep encounters an error
It throws a message to the console
What happens it grep matches a pattern
It prints out the matching line
What happens if grep doesn’t find a match
It returns to the command prompt
spaces (either spaces or tabs)
[[:space:]]
What is a character literal
The charcter’s face or symbol is what it means. There is no other possible meaning.
This comes up in regular expressions because sometimes we can use symbols to indicate special patterns. If we want to search for the specific symbol instead of the pattern, we need to adjust how we search for it.
What is considered a word
Characters with whitespace or special charcters on either side. The whitespace and special characters indicate the word boundaries (Where a word begins and ends).
tab character
\t