Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part II: Regular Expression 1. Chose match(es) for each given basic or extended regular expression (maybe multiple correct matches) e.g. Extended regular expression: ab+a a)

Part II: Regular Expression

1. Chose match(es) for each given basic or extended regular expression (maybe multiple correct matches) e.g.

Extended regular expression: ab+a a) ababa b) aba c)abba d)aabbaa e)aa Answer:b,c (Because matched string should begin and end with a and b occurs at least once between leading and ending a)

Note: question 1) to 4) are for basic regular expressions, question 5) to 12) are for extended regular expressions.

1) a(ab)*a (a) a(ab))a (b) aaba (c) aabab (d) aa(abab)aa (e) aa

2) a.[bc]+ (a)azbc+ (b) az (c) azbcbc+ (d) acc (e)acc+

3) a.[0-9] (a)azz (b) a0z (c) a01 (d) a0a (e)aza

4) (very )+(cool )?(good|bad) weather (a)good weather (b) (very) good weather (c) cool weather (d) very cool bad weather (e) (very )+(cool )?(good|bad) weather

5) abc{1,2} (a) abcbc (b) abcc (c) abc (d) bcbc (e)abcbcbc

6) (a|b)*c (a) ababc (b) abc (c) abab (d) bc (e)abc

7) a.[bc]+ (a)azbc (b) az (c) azbcbc (d) acc (e)acz

8) [a-z]+[\.\?!] (a)easy! (b) Game? (c) a+1. (d) easy?hard (e)yes\

9) [a-z]+[.?!]\s *[A-Z] (hint: \s matches any space character) (a)Grade. A (b) book. Z (c) E. G (d) Level. a (e)index?a

10) (very )+(cool )?(good|bad) weather (a)good weather (b) very good weather (c) cool weather (d) very cool bad weather (e)cool good weather

11) -?[0-9]+ (a)+3320 (b) -3320 (c) +32.0 (d) .32 (e)2/3

12) -?[0-9]*\.?[0-9]* (a)+3320 (b) -3320 (c) +32.0 (d) .32 (e)2/3

2. Write down the extended regular expression for following questions

E.g. Social security number in the format of 999-99-9999. Answer: [0-9]{3}-[0-9]{2}-[0-9]{4} (10 points, each 2 points)

1) Valid URL beginning with http://. (e.g. https://www.cmu.edu)

2) Valid variable name following the two rules below:

Must begin with a letter of the alphabet, an underscore, or ( _ ), or a dollar sign ($)

After the first initial letter, variable names may also contain letters and the digits 0 to 9.

3) Valid email address, assuming a-z,0-9,_,. are valid characters for user id and domain name has to be end with either .com or .net (e.g. aabb_123.xy@g3.com, cdcd@12_3.net)

4) Phone number in any of the following format: 999-9999999,999-999-9999, (999)-9999999. (Note: all of these formats should be matched by a single regular expression)

5) Valid HTML link tag with the format: ... . (e.g. OReilly Media , Download Test )

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Transaction Processing

Authors: Philip M. Lewis, Arthur Bernstein, Michael Kifer

1st Edition

0201708728, 978-0201708721

More Books

Students also viewed these Databases questions