In: Computer Science
Using Python answer the following questions.
1. Describe the class of strings matched by the following
regular expressions. Provide examples
that can be captured by the regular expression pattern.
(a) [A-Za-z]+
(b) ^[A-Za-z]+.\d$
2. Which of the following matches regexp /(very )+(thick
)?use(ful|less) book/?
Explain why.
A. very thick book
B. very very useful book
C. thick useless book
D. very useless book
1. Describe the class of strings matched by the following regular expressions. Provide examples that can be captured by the regular expression pattern. (a) [A-Za-z]+ => Above Regex match An string which is not empty and contains only alphabets (b) ^[A-Za-z]+.\d$ => The regex matches a string which starts with any number of alphabets, then one character of any type, And ending on a digit. 2. Which of the following matches regexp /(very )+(thick )?use(ful|less) book/? Explain why. A. very thick book => Does not match, because it does not contain "use" B. very very useful book => Matches.. Very can be repeated any number of times.. thick is optional. Any of ful or less need to be used. C. thick useless book => Does not mathc, Because very should be occurring 0 or more times. D. very useless book => Matches.. Thick is optional, So it matched.
************************************************** Thanks for your question. We try our best to help you with detailed answers, But in any case, if you need any modification or have a query/issue with respect to above answer, Please ask that in the comment section. We will surely try to address your query ASAP and resolve the issue.
Please consider providing a thumbs up to this question if it helps you. by Doing that, You will help other students, who are facing similar issue.