Metacharacters Flashcards

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

What does . metacharacter match?

A

any single character except for a newline character “(\n)”

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

What does + metacharacter match?

A

one or more occurrences of the preceding character or group

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

Which symbol denotes the start of a line or string?

A

^

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

What does \w match?

A
  • any word character, which includes alphanumeric characters (letters and digits) as well as underscores _
  • equivalent to the character class [A-Za-z0-9_]
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What does \s match?

A

any whitespace character, which includes spaces, tabs, and newline characters

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

What does \D match?

A

any character that is not a digit - negation of \d

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

What does \d match?

A

any digit, which is equivalent to the character class [0-9]; represents a single numeric digit from 0 to 9

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

What is the role of parentheses () in regular expressions?

A

primarily used for grouping, capturing, and controlling the precedence of subpatterns within a larger pattern

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

How are parentheses () used for grouping?

A
  • useful when there is a need to apply a quantifier (e.g., *, +, ?, {}) to a specific group of characters
  • helps to ensure that all grouped elements are treated as a single unit within a pattern
(abc){2}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are word characters?

A

includes [A-Za-z0-9_]

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

What does \w+ mean?

A

one or more characters are being matched

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

What does .* match?

A

any character (except newlines) zero or more times

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