In: Computer Science
. Give an example of a string represented by each of the following regular expressions
• 0+ 1+ (11)* 0?
• [0-9]+ ( (E|e) (\+|\-)? [0-9]+ )?
• ([a..z] ([a..z] | [0..9])*)
Examples of the various string generated by the following regular expressions:
• Regular Expression sign and meaning:
* = Zero or more occurrences
+ = One or more occurrences
? = Zero or One occurrence
| = Logical OR
[..] = Any one character from specified range
(..) = All characters from specified range
\ = Escape sequence (\+ matches the with special character +)
(1) 0+ 1+ (11)* 0?
Example String: 01110
Other Examples:
• 010
• 01
• 0111110
• 0111
(If regular expression is not having free-spacing mode then string would look like: 0 1 11 0)
(2) [0-9]+ ( (E|e) (\+|\-)? [0-9]+ )?
Example String: 1004E+68
Other Examples:
• 1234
• 88e-7684
• 44E+1234
• 9999e+44
(If regular expression is not having free-spacing mode then string would look like: 1004 E + 68)
(3) ([a..z] ([a..z] | [0..9])*)
Example String: m9
Other Examples:
• rddd
• h4444
• abcd9
• hello4
(If regular expression is not having free-spacing mode then string would look like: m 9)