Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

**************Regular Expressions ( Regex Syntax) answer all the multiple choice

ID: 642808 • Letter: #

Question

**************Regular Expressions ( Regex Syntax) answer all the multiple choice questions.*************

Question 1

Consider the following regular expression:

0[1-9]|1[0-2]

Which of the following strings does NOT match?

00

01

10

12

Question 2

Consider the following regular expression (from the previous question):

0[1-9]|1[0-2]

What type of string does this expression validate?

A.

Any 2 digits.

B.

A 2-digit representation of the year.

C.

A 2-digit representation of the month.

D.

A 2-digit representation of the day.

Question 3

Which regular expression best matches a 2-character representation of a state abbreviation requiring uppercase letters?

A.

[A-Z][A-Z]

B.

[A-Z|a-z][A-Z|a-z]

C.

DD

D.

ww

Question 4

Which regular expression best matches the representation of time using a 24-hour clock, e.g. military or computer time?

A.

/d/d:/d/d

B.

^([0-1][0-9]|2[0-3])[:][0-5][0-9]$

C.

^[0-2]?[0-9]:[0-5][0-9]$

D.

/d?/d:/d/d

5 points

Question 5

Which regular expression best matches an asu email address?

A.

w+@asu.edu

B.

w+@asu.edu

C.

w*@asu.edu

D.

W+@asu.edu

5 points

Question 6

Which regular expression best matches a 10-digit phone number with or without dashes?

A.

d+

B.

dddddddddd

C.

d+-?d+?d+

D.

ddd-?ddd-?dddd

Question 7

There is an additional meta-character in regular expressions {n},
which means to match the preceding character n times exactly.
For example, a 3-digit number can be matched by [0-9]{3}.

Which of the following regular expressions best matches a 16 digit credit card number?

A.

ddddddddddddddd

B.

D{16}

C.

d{16}

D.

d[16]

Question 8

Note that the syntax {n,m} matchese the preceding character at least n times but not more than m times.
Which of the following regular expressions best matches an ip address?

A.

d{3}.d{3}.d{3}.d{3}

B.

d{1,3}.d{1,3}.d{1,3}.d{1,3}

C.

d{1,3}.d{1,3}.d{1,3}

D.

d{1,3}.d{1,3}.d{1,3}.d{1,3}

  

Question 9

Which of the following regular expressions best determines whether a password consists of alphanumeric characters and is at least 6 in length but no longer than 12?

A.

w{6,12}

B.

w[6,12]

C.

W{6,12}

D.

W[6,12]

A.)

00

B.)

01

C.)

10

D.)

12

Explanation / Answer

Question 1
A) 00

Question 2
C) A 2-digit representation of the month.

Question 3
A) [A-Z][A-Z]

Question 4
B) ^([0-1][0-9]|2[0-3])[:][0-5][0-9]$

Question 5
B) w+@asu.edu

Question 6
D) ddd-?ddd-?dddd

Question 7
C) d{16}

Question 8
B) d{1,3}.d{1,3}.d{1,3}.d{1,3}

Question 9
A) w{6,12}