Regex Flashcards

(17 cards)

1
Q

Definition and Purpose of Regex

A

■ Regular expressions or regex is a specialized language and essential administrator tool used to describe and match patterns within text

■ Regex is not a command

■ Regex is a series of character-based structures that define patterns used for searching text

■ Regex allows rapid location of specific patterns in large amounts of text

■ Regex is useful for troubleshooting and incident response

■ Regex is used to filter command output and automate text processing tasks
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Wildcard character

A

. matches any single character

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

. example

A

c.t matches cat cot or c-t

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

\ character

A

treats the next character as a literal

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

\ character example

A

cowa.bunga matches only cowa.bunga not cowaabunga or cowa-bunga

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

^ anchor

A

anchors pattern to beginning of line

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

^ example

A

^Hello matches lines beginning with Hello

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

$ anchor

A

anchors pattern to end of line

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

$ example

A

world$ matches lines ending with world

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

[a-z]

A

matches any single lowercase letter a to z

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

[0-9]

A

matches any single digit

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

[a-z] example

A

ox matches fox box and pox

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

?

A

matches zero or one occurrence of the preceding element

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

*

A

matches zero or more occurrences of the preceding element

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

+

A

matches one or more occurrences of the preceding element

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

{n}

A

matches exactly n occurrences of the preceding element