Question

Which of the following strings would match the regular expression: [a-z]+[\.\?!] A. Shout! B. Cry C....

Which of the following

strings would match the regular expression:

[a-z]+[\.\?!]

A. Shout!

B. Cry

C. weep.?

D. Laugh

E. smile?

What is the answer and why. go through each expression please. eg what does\. do \?! do etc

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Which of the following strings would match the regular expression:

[a-z]+[\.\?!]

Answer: (E) smile?

Description:

• In given regular expression, [a-z] means "a character from a through z"

• [a-z]+ means "[a-z] one or more time"

• \. indicates Special use of the " . " symbol.

• \? indicates Special use of the " ? " symbol.

• [\.\?!] means "." or "?" or "!"

Strings that will match the expression:

(E) smile?Match

Description:

In "smile?" string, "smile" matches the [a-z]+ form and  "?" matches the "\?" form. So, the string "smile?" matches the [a-z]+[\.\?!] regular expression.

Strings that will not match the expression:

(A) Shout!Not Match

Description:

In "Shout!" string, 'S' would not match the [a-z]+ form. So, the string "Shout!" does not matches [a-z]+[\.\?!] regular expression.

(B) CryNot Match

Description:

In "Cry" string, 'C' would not match the [a-z]+ form. So, the string "Cry" does not matches [a-z]+[\.\?!] regular expression.

(C) weep.?Not Match

Description:

In "weep.?" string, the character "." and "?" both are there which would not match the [\.\?!] form. So, the string "weep.?" does not matches [a-z]+[\.\?!] regular expression.

(D) LaughNot Match

Description:

In "Laugh" string, 'L' would not match the [a-z]+ form. So, the string "Laugh" does not matches [a-z]+[\.\?!] regular expression.

Add a comment
Know the answer?
Add Answer to:
Which of the following strings would match the regular expression: [a-z]+[\.\?!] A. Shout! B. Cry C....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT