Regex 101 Flashcards

1
Q

What is Regex?

A

Short for regular expression, a regex is a string of text that allows you to create patterns that help match, locate, and manage text.

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

What is the left and the right side of this called?:

action=time532

A

field and value

Both they create a field-value pair

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

What does Regex do?

A

a) Filtering - it eliminates unwanted data from your searches
b) Matching - advanced pattern matching to find the results you need
c) Field extraction - labels bits of data that can be used for further calculation and analysis

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

What does Control Characters (anchors) do?

A

They tell regex where to start and stop looking

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

What control characters do you know? What do they do?

A

^ - start of a line

$ - end of a line

\b - whole words only

\B - bordered by word characters

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

What are character Classes?

A

Character classes distinguish kinds of characters such as, for example, distinguishing between letters and digits

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

What are the character classes that you know? What do they do?

A

\s - white space

\S - not a white space

\d - digit

\D - non-digit

\w -word-character (includes letters, numbers and underscore)

\W - non-word character

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

How to define symbolic character?

A

use \

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

How to anchor start of a line?

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

How to anchor end of a line?

A

$

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

How to define the border by whole words only?

A

\b

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

How to define the border by word characters?

A

\B

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

What’s the character class for white space?

A

\s

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

What’s the character class for not a white space?

A

\S

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

What’s the character class for digit?

A

\d

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

What’s the character class for non-digit?

A

\D

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

What’s the character class for word-character?

A

\w

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

What’s the character class for non-word character?

A

\W

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

What are operators?

A

They define how many of character types to grab

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

What operators you know? What do they do?

A

* - zero or more

+ - one or more

? - Zero or more

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

What is the Operator for zero or more?

A

*

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

What is the operator for one or more?

A

+

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

What is the operator for zero or one?

A

?

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

What is a Greedy regex?

A

Greedy regex means that your regex statement is using a operator that keeps gobbling up matches until it is interrupted

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

What is a Lazy regex?

A

Lazy regex means your regex will only match the first occurence of the pattern you are looking for before it stops

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

What are special characters?

A

Those are the characters that symbolize something else.

For Example *+?$/[]{}()

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

What is the symbol for “OR” condition?

A

|

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

What is the special character for matching any character?

A

.

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

What is a protection character?

A

It identifies given letter as a special character, or special character as a literal match

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

What is the protection character?

A

\ (backslash, escape)

31
Q

What are the inclusion characters?

A

[]

32
Q

What are the exclusion characters?

A

[^]

33
Q

What is repetition?(regex)

A

Tells regex how many times you want to pick up on an pattern

34
Q

How would you use pattern repetitions in regex?

A
35
Q

How would you set up logical groupings?

A

With ()

36
Q

How would you use logical groupings?

A
37
Q

What are named capture groups?

A

They extract the value and assign named field to it

38
Q

How would you use Named Capture Groups?

A
39
Q
A
40
Q

This is the “reversed” card. It first displays you the answer and you have to guess the question part of it.

They tell regex where to start and stop looking

A

What does Control Characters (anchors) do?

41
Q

This is the “reversed” card. It first displays you the answer and you have to guess the question part of it.

^ - start of a line

$ - end of a line

\b - whole words only

\B - bordered by word characters

A

What control characters do you know? What do they do?

42
Q

This is the “reversed” card. It first displays you the answer and you have to guess the question part of it.

Character classes distinguish kinds of characters such as, for example, distinguishing between letters and digits

A

What are character Classes?

43
Q

This is the “reversed” card. It first displays you the answer and you have to guess the question part of it.

\s - white space

\S - not a white space

\d - digit

\D - non-digit

\w -word-character (includes letters, numbers and underscore)

\W - non-word character

A

What are the character classes that you know? What do they do?

44
Q

This is the “reversed” card. It first displays you the answer and you have to guess the question part of it.

use \

A

How to define symbolic character?

45
Q

This is the “reversed” card. It first displays you the answer and you have to guess the question part of it.

A

How to anchor start of a line?

46
Q

This is the “reversed” card. It first displays you the answer and you have to guess the question part of it.

$

A

How to anchor end of a line?

47
Q

This is the “reversed” card. It first displays you the answer and you have to guess the question part of it.

\b

A

How to define the border by whole words only?

48
Q

This is the “reversed” card. It first displays you the answer and you have to guess the question part of it.

\B

A

How to define the border by word characters?

49
Q

This is the “reversed” card. It first displays you the answer and you have to guess the question part of it.

\s

A

What’s the character class for white space?

50
Q

This is the “reversed” card. It first displays you the answer and you have to guess the question part of it.

\S

A

What’s the character class for not a white space?

51
Q

This is the “reversed” card. It first displays you the answer and you have to guess the question part of it.

\d

A

What’s the character class for digit?

52
Q

This is the “reversed” card. It first displays you the answer and you have to guess the question part of it.

\D

A

What’s the character class for non-digit?

53
Q

This is the “reversed” card. It first displays you the answer and you have to guess the question part of it.

\w

A

What’s the character class for word-character?

54
Q

This is the “reversed” card. It first displays you the answer and you have to guess the question part of it.

\W

A

What’s the character class for non-word character?

55
Q

This is the “reversed” card. It first displays you the answer and you have to guess the question part of it.

They define how many of character types to grab

A

What are operators?

56
Q

This is the “reversed” card. It first displays you the answer and you have to guess the question part of it.

* - zero or more

+ - one or more

? - Zero or one

A

What operators you know? What do they do?

57
Q

This is the “reversed” card. It first displays you the answer and you have to guess the question part of it.

*

A

What is the Operator for zero or more?

58
Q

This is the “reversed” card. It first displays you the answer and you have to guess the question part of it.

+

A

What is the operator for one or more?

59
Q

This is the “reversed” card. It first displays you the answer and you have to guess the question part of it.

?

A

What is the operator for zero or one?

60
Q

This is the “reversed” card. It first displays you the answer and you have to guess the question part of it.

|

A

What is the symbol for “OR” condition?

61
Q

This is the “reversed” card. It first displays you the answer and you have to guess the question part of it.

.

A

What is the special character for matching any character?

62
Q

This is the “reversed” card. It first displays you the answer and you have to guess the question part of it.

[]

A

What are the inclusion characters?

63
Q

This is the “reversed” card. It first displays you the answer and you have to guess the question part of it.

[^]

A

What are the exclusion characters?

64
Q
A

\w+[A-Z]

65
Q
A

(\d+-){2}\d+ \d+-\d+-\d+

66
Q
A

\w+,\s[A-Z]+

67
Q
A
68
Q
A

\b[A-Z]\w+

69
Q
A

\w+(?=@)

70
Q

What is negative lookahead and how it works?

A

(?!)

Find experssion A where expression B does not follow:

A(?!B)

71
Q

What is positive lookahead and how it works?

A

(?=)

Find experssion A where expression B follows:

A(?=B)

72
Q

What is positive lookbehind and how does it work?

A

(?<=)

Find expression A where expression B precedes:

(?<=B)A

73
Q

What is negative lookbehind and how does it work?

A