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

4. Construct regular expressions for the following languages over the alphabet {a, b}: a. Strings that...
4. Construct regular expressions for the following languages over the alphabet {a, b}: a. Strings that do not begin with an “a”. b. Strings that contain both aa and bb as substrings. 5. Let ? = {? ?? ?? ? | ? > ? + ?}. a. List all strings of length 7. (use power notation: i.e. aabbbbaaaaaaaa is a2b 4a 8 ) b. Use the Pumping Lemma for Regular Languages to prove that L is not regular.
Are the following languages regular languages or not ? Justify your answer with a proof. ?...
Are the following languages regular languages or not ? Justify your answer with a proof. ? = {? | ? represents an integer strictly greater than 2020}, on alphabet Σ = {0,…,9}. ? = {? | |?|a > |?|b} on alphabet Σ = {a,b} ? = {? | ? is the code of a LOOP program syntactically correct } ? = {02?| ? ∈ ℕ} sur alphabet Σ = {0}.
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
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}.
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...
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.
. 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])*)
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)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT