N6. Java Regex Flashcards

1
Q

What is a possible use of a Regular Expression?

A

used for parsing and checking user inputs and messages within protocol

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

REGEX

^ character

A

beginning of a line

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

REGEX

$ character

A

end of a line

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

REGEX

\ character

A

escapes a meta character

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

REGEX

\d

A

[0-9] digits

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

REGEX

\D

A

[^0-9] (anything other than digits 0-9)

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

REGEX

\w

A
word character 
(same as [A-Za-z0-9_])
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

REGEX

\b

A

word boundary

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

REGEX

[abc]

A

match ‘a’, ‘b’, or ‘c’

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

REGEX

[^abc]

A

match anything but ‘a’, ‘b’, or ‘c’

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

REGEX

[a-z]

A

match characters in the range ‘a’-‘z’

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

REGEX

repetition characters

A

{ } curly brackets

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q
REGEX
define a class of characters
A

[ ] square brackets

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

REGEX

\d{2,5}

A

between 2 and 5 digits

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

REGEX

\d{5,}

A

5 or more digits

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

REGEX

\s

A
whitespace character
(distinction with \\S - non-whitespace character)
17
Q

REGEX quantifiers

* symbol

A

0 or more occurrences

18
Q

REGEX quantifiers

+ symbol

A

1 or more occurrences

19
Q

REGEX quantifiers

? symbol

A

0 or 1 occurrence

20
Q

REGEX

define a group

A

( ) round brackets