Basics Flashcards

Basic elements of regex

You may prefer our related Brainscape-certified flashcards:
1
Q

Indicates the start of the expression

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Indicates the end of the expression

A

$

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

lowercase characters

A

[[:lower:]]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

alphabetical characters

A

[[:alpha:]]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Numbers

A

[[:digits:]]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Punctuation

A

[[:punct:]]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Uppercase

A

[[:upper:]]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Wildcard for 1 character

A

.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Escape character

A

\

So when you need to search for a period, you’d enter .

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Wildcard for multiple charcters

A

*

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Check for a specific number of characters

A

{2n}\ for example ‘T.{2}n’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Back references

A

grep ‘(.)(\1)’ this finds any scenario where there are two identical charcters, side by side

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is a token

A

Symbol character that has a specific meaning, rather than purely it’s face value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is a character class

A

A way to check for a specific set of characters

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

whitespace

A

[[:space:]]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What happens if grep encounters an error

A

It throws a message to the console

17
Q

What happens it grep matches a pattern

A

It prints out the matching line

18
Q

What happens if grep doesn’t find a match

A

It returns to the command prompt

19
Q

spaces (either spaces or tabs)

A

[[:space:]]

20
Q

What is a character literal

A

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.

21
Q

What is considered a word

A

Characters with whitespace or special charcters on either side. The whitespace and special characters indicate the word boundaries (Where a word begins and ends).

22
Q

tab character

A

\t