Topic 9 - Regular Expressions Flashcards

1
Q

matches any single character except newline

A

.

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

matches zero or more occurrence of the previous single character

A

*

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

escape character

A

\

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

matches the beginning of a line

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

matches the end of a line

A

$

do not use $ with double quotes - problems with the shell

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

-matches a single character in a set or range of characters

A

[..]

Eg: a[bc]
matches a string that has a followed by b or c
- combine […] with * to match repeated sets

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

[^…]

A

matches the complement of whats inside the square brackets

Eg: [^a-zA-Z] will match a string that does not have any of the English letters

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

\less-than-sign

A

matches the BEGINNING of a regular expression word

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

>

A

matches the END of a regex word

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

(….)

\n

A
  • remembers a portion of regular expression

- recalls the remembered portion where n is a digit from 1 to 9

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

X{m}

X{m,n}

A
  • matches exactly m repeated of the one character regular expression X
  • matches m to n repeats of X
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

X{m,}

A

matches m or more repeats of X

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

matches simply m or fewer repeats of X

A

X{,m}

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

matches a string that has a $ before one digit

A

$\d

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

matches any string that starts with The

A

^The

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

matches a string that ends with end

17
Q

Matches lines which only have the words:

The end

18
Q

matches a string that has ab followed by one or more c

19
Q

matches a string that has ab followed by zero or more c

20
Q

matches a string that has ab followed by zero or one c

21
Q

matches a string that has ab followed by 2 c

ie: abcc

22
Q

What are the quantifier operators?

A
  • ,+ ,? and {}
23
Q

matches a string that has ab followed by 2 or more c

24
Q

matches a string that has ab followed by 2 up to 5 c

25
matches a string that has a followed by zero or more | copies of the sequence bc
a(bc)*
26
matches a string that has a followed by 2 up to 5 copies of the sequence bc Eg: abcbc abcbcbcbc
a(bc){2,5}
27
What are the character classes?
\d \w \s and . \d matches a single character that is a digit \w matches a word character (alphanumeric character plus underscore) \s matches a whitespace character (includes tabs and line breaks) . matches any character
28
Match a single digit
\d
29
matches a single non-digit character
\D
30
matches a single non-word character
\W
31
matches a single non-space character
\S
32
matches the same text that was | matched by the first capturing group
([abc])\1