Question

In: Computer Science

Describe the languages specified by the following regular expressions: 1. \\(_+)/ 2. (\(740\)...-...)|(...-...) (The alphabet is...

Describe the languages specified by the following regular expressions:

1. \\(_+)/

2. (\(740\)...-...)|(...-...) (The alphabet is {1,2,3,4,5,6,7,8,9,0})

Solutions

Expert Solution

1.The first regular expression is \\(_+)/

\ is an escaping character which is used to escape a special character.So here // means / in the string will be matched.

Inside the bracket (), _+ is present. + implies matching one or more occurrence of the previous character . Therefore, _+ means matching one or more occurence of _ (underscore ) in the string.

/ denotes the end character will be match to /.

From the above details we can conclude that the given regular expression will matches strings like,

\_/, \__/, \___/, \____/, etc.

2.The second regular expression is (\(740\)...-...)|(...-...)

\ is an escaping character which is used to escape a special character.So here \( matches ( of the string.

740 will be matched to 740 in the string

\) will matches ) in the string

. means any character except newline character will be matched .Here three dots are present.So... denotes the string will get matches to any 3 characters other than newline.

- will matches the - in the string

Therfore (\(740\)...-...) means, this regular expression matches to the string contain (740) then any 3 characters other than newline then - (hyphen) and then any 3 characters other than newline.

(...-...) means this regular expression matches the to the string contain any 3 characters other than newline and hyphen - and any 3 characters other than newline.

The given regular expression is, (\(740\)...-...)|(...-...) which means (\(740\)...-...) or (...-...)

So there is many combination of strings which matches the given regular expression. Some of examples are,

(740),78-91'

218-702

(740)13>-076

1:}-517


Related Solutions

Determine whether or not the following languages are regular. If the language is regular then give...
Determine whether or not the following languages are regular. If the language is regular then give an NFA or regular expression for the language. Otherwise, use the pumping lemma for regular languages or closure properties to prove the language is not regular. 1) L = { 0 n1 k : k ≤ n ≤ 2k} 2) L = { 0 n1 k : n > 0, k > 0 } È { 1 k0 n : k > 0, n...
Are the following languages over {a, b} regular? If they are then prove it. If they...
Are the following languages over {a, b} regular? If they are then prove it. If they are not prove it with the Pumping Lemma a) {ap | p is a prime number} b) {xax | x Î{a,b}*} (start by listing some strings in, not in, the language
3. Are the following languages A and B over the alphabet Σ = {a, b, c,...
3. Are the following languages A and B over the alphabet Σ = {a, b, c, d} regular or nonregular? • For a language that is regular, give a regular expression that defines it. • For a nonregular language, using the pumping lemma prove that it is not regular. (a) A = {d 2j+1c k+1 | j ≥ k ≥ 0} · {c r+2b 2s+3 | r ≥ 0 and s ≥ 0} (b) B = {a 2j+2b k+3c j+1...
Formal Languages Give a regular expression for each of the following languages: L2a = {w ?...
Formal Languages Give a regular expression for each of the following languages: L2a = {w ? {0,1}* | w corresponds to the binary encoding of non-negative integers that are evenly divisible by 4 L2b = {w ? {a,b}* | w contains at least one 'a' and exactly two b's} L2c = {w ? {0, 1, 2}* | w starts with a 2, ends with a 1 and contains an even number of 0's}.
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.
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)
4. Rewrite the following pseudocode segment using a loop structure in the specified languages: k =...
4. Rewrite the following pseudocode segment using a loop structure in the specified languages: k = (j + 13) / 27 loop:       if k > 10 then goto out       k = k + 1       i = 3 * k - 1       goto loop out: . . . a. C++ b. Python c. Ruby Assume all variables are integer type. Discuss the relative merits of the use of these languages for this particular code.
Use the pumping lemma to show that the following languages are not regular. A a. A1={0^n...
Use the pumping lemma to show that the following languages are not regular. A a. A1={0^n 1^n 2^n | n≥0} b. A2 = {www | w ∈ {a,b}∗} A c. A3 ={a^2^n | n≥0} (Here, a^2^n means a string of 2^n a’s.) A ={a3n |n > 0 }
Use the pumping lemma to show that the following languages are not regular (c) (5 pts)...
Use the pumping lemma to show that the following languages are not regular (c) (5 pts) Let Σ = {0, 1, −, =} and SUB = {x = y − z | x, y, z are binary integers, and x is the result of the subtraction of z from y}. For example: 1 = 1 − 0, 10 = 11 − 01 are strings in SUB but not 1 = 1 − 1 or 11 = 11 − 10.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT