RegEx Flashcards

1
Q

What file header do you need for RegEx

A

include <regex></regex>

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

What symbols are used to represent a set or a range

A

Square brackets [set/range]

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

What symbol represents a repeating pattern

A

The plus sign +

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

How do you represent a backslash (for c++)

A

Four escape sequences \\

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

What version of c++ supports raw string literals

A

11

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

What is the syntax of raw string literals

A

Use quotes after an R, like R”" for a single \ char

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

Only match beginning of line

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

Any character between pattern

A

.

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

Any character starting or ending

A

?

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

Repeat exactly x times

A

{x}

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

Repeat at least x times

A

{x,}

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

Repeat between x and y times

A

{x,y}

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

What are the 6 equivalent class names for a regular expression

A
  1. [[:upper:]] = [A-Z]
  2. [[:lower:]] = [a-z]
  3. [[:digit:]] = [0-9]
  4. [[:alnum:]] = [0-9a-zA-Z]
  5. [[:space:]] = space or tab
  6. [[:alpha:]] = [a-zA-Z]
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the negation option for grep

A

-v (for inVerted)

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

What are the 9 sort options

A
  1. -c (already sorted?)
  2. -m (merge sorted files)
  3. -u (only unique lines)
  4. -o (output file, same as >)
  5. -b (ignore leading blanks)
  6. -n (numerical)
  7. -t (delimiter)
  8. -r (reverse)
  9. +/-n (begin/ignore field number)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Use 3rd field for sorting numerically

A

+2n

17
Q

Split up a sort into fields per line, delimited by semicolons

A

-t\;

18
Q

Use 4th field to sort

A

-k4