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

Answer the following regular expressions questions Q1 Choose a pattern to find a

ID: 3732895 • Letter: A

Question

Answer the following regular expressions questions

Q1 Choose a pattern to find all dollar values from $10.00 to $99.99.
1) $[1-9]*[0-9]
2) $[1-9][0-9].[0-9][0-9]
3) $[1-9][0-9].[0-9][0-9]
4) $[1-9][0-9].[0-9].
Q2 Which of the following will the pattern [Aa].[Tt] include?
1) overacting
2) Atratat
3) A.S.T.
4) batch
Q3 Choose the pattern that will find Fairway at the beginning of a line
1) ^Fairway
2) ^Fairway
3) ^[Fairway]
4) [0]Fairway
Q4 Choose the pattern that finds all filenames in which the first letters of the filename are astA, followed by a
digit, followed by the file extension .txt.
1) astA[[:digit:]].txt
2) astA[[0-9]].txt
3) astA..txt
4) astA[[:digit:]].txt
Q5 What's the difference between [0-z]+ and w+ ?
1) The first one accepts 0 and z and the other doesn't.
2) The first one doesn't allow for uppercase letters.
3) The first one accepts more punctuation characters than the second one.
4) Nothing. They're identical.
Q6 What does the regular expression (d{1,2}/d{1,2}/d{4} most likely represent?
1) An American ZIP code
2) A date
3) A phone number
4) A price
Q7 What does the regular expression [a-zA-Z0-9_]{3,14} most likely represent?
1) An e-mail address
2) A street address
3) A username
4) A set of X and Y coordinates
Q8 What does the regular expression ^((0?[1-9]|1[012])(:[0-5]d){0,2}( [AP]M))$|^([01]d|2[0-3])(:[0-5]d){0,2}$
most likely represent?
1) A street address
2) A name
3) A time
4) A date
Q9 The regular expression ^d{5}-d{4}|d{5}|[A-Z]d[A-Z] d[A-Z]d$ is designed to validate American ZIP Codes
and Canadian Postal Codes but there are two problems with it. What is one of the flaws?
1) It doesn't allow for leaving the space out after the third character in the Canadian Postal Code.
2) American ZIP codes that start with 0 aren't accepted.
3) It requires that the string contain an American ZIP Code followed by a Canadian Postal Code.
4) It allows for American ZIP codes with 9 digits.
Q10 What does the regular expression ^([0-3]|[0-9][0-9]|4[0-5][0-9]|46[0-6])$ most likely represent?
1) A range of numeric values from 0 to 499.
2) A range of numeric values from 399 to 499.
3) A range of numeric values from 399 to 466
4) A range of numeric values from 0 to 466.
Bonus: Regular Expression Golf (+1 point for an expression that works, +1 additional for having the shortest)
What is the shortest regular expression you can come up with that matches the names of only the Normal
Pokemon types found in this list:
http://bulbapedia.bulbagarden.net/wiki/List_of_Pok%C3%A9mon_by_Kanto_Pok%C3%A9dex_numbe

Explanation / Answer

Answers)

Q1 Choose a pattern to find all dollar values from $10.00 to $99.99.

Answer)

The correct answer option is:

3) $[1-9][0-9].[0-9][0-9]

This is because, after decimal two integers are mandatory. Thus .[0-9][0-9] is valid. The whole numbers have to be greater than or equal to 10. Thus [1-9][0-9] is true.

Q2 Which of the following will the pattern [Aa].[Tt] include?

Answer)

AST

overacting- are correct answers.

A and a T are separated by one character, without regard to case, so AST and overacting match.

Q3 Choose the pattern that will find Fairway at the beginning of a line

Answer)

^FarAway is the correct option

^ attaches and searches for the work at the beginning of the line.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote