Question

In: Computer Science

. Give an example of a string represented by each of the following regular expressions •...

. 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])*)

Solutions

Expert Solution

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)


Related Solutions

For each of the following Perl regular expressions, give a complete and precise description of the...
For each of the following Perl regular expressions, give a complete and precise description of the function of the regular expression, plus a related example string: (a) /"([^"]*)"/ (b) /[-+]?\d+(\.\d*)?F\b/ (c) /(\D{2,}).*\[\1\]/ (d) /((.*?)\d)\s\2/ (e) /^[0-9]+\/\d+([+\-*\/]\=|([+]{2}|[-]{2}));$/
Regular => Context-Free Give a proof by induction on regular expressions that: For any language A,...
Regular => Context-Free Give a proof by induction on regular expressions that: For any language A, if A is regular, then A is also context-free. You may assume that the statements from the previous Closure under Context-Free Languages problem are proved. R is a regular expression if RR is: a for some a∈alphabet Σ, the empty string ε, the empty set ∅, R​1​​∪R​2​​, sometimes written R​1​​∣R​2​​, where R​1​​ and R​2​​ are regular expressions, R​1​​∘R​2​​, sometimes written R​1​​R​2​​, where R​1​​ and...
Regular Expressions Assignment Write a regular expression for each of the following. Can you show output...
Regular Expressions Assignment Write a regular expression for each of the following. Can you show output please. A blank line (may contain spaces) Postal abbreviation (2 letters) for State followed by a space and then the 5-digit zip code A KU student username (Ex. lpork247) A “valid” email address (also explain how you defined “valid”) A SSN pattern (ddd-dd-dddd)
5 Regular => Context-Free Give a proof by induction on regular expressions that: For any language...
5 Regular => Context-Free Give a proof by induction on regular expressions that: For any language A, if A is regular, then A is also context-free. You may assume that the statements from the previous Closure under Context-Free Languages problem are proved.
Linux regular expressions: file name: lab3test.txt Create regular expressions that meet the following criteria. You may...
Linux regular expressions: file name: lab3test.txt Create regular expressions that meet the following criteria. You may use grep or egrep to answer these questions. 1.Match any lines that contain a phone number with the format 222-222-2222.
linux Regular expressions file name: lab3test.txt Create regular expressions that meet the following criteria. You may...
linux Regular expressions file name: lab3test.txt Create regular expressions that meet the following criteria. You may use grep or egrep to answer these questions. 1.Display all lines where the employee’s age is greater than 40 years old. Again, don’t think of this as a number, think of it as a series of characters.
RegEx (Regular Expressions) Make 8 regular expressions to filter a specific data set in Java and...
RegEx (Regular Expressions) Make 8 regular expressions to filter a specific data set in Java and explain what they do.
Give an example of how each Newtonian Law of Motion is represented in walking. Briefly explain...
Give an example of how each Newtonian Law of Motion is represented in walking. Briefly explain your position in a short paragraph.
Give a high-level description of what regular expressions are, and how JavaScript uses them.
Give a high-level description of what regular expressions are, and how JavaScript uses them.
Give an example of each of the following and how they are used in the example...
Give an example of each of the following and how they are used in the example you gave: 1. Enterprise Information Security Policy (EISP) 2. Issue-Specific Security Policy (ISSP) 3. System-Specific Security Policy (SysSP)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT