Give the best regular expression for each of the following in / delimited form. For example, the regular expression to find a string that is a single “a” would be /^a$/
You may NOT use the negation syntax in the format (?!)
1. Find a regular expression that will find strings that start with anything but the empty string and contains the string apple.
The regular expression is: ^(?!\s*$).+a{1}p{2}l{1}e{1}
The first half of the expression will check for the string is empty or not and the second half of the expression would check for the word "apple".
Give the best regular expression for each of the following in / delimited form. For example, the ...
Regular Expression processor in Java Overview: Create a Java program that will accept a regular expression and a filename for a text file. The program will process the file, looking at every line to find matches for the regular expression and display them. Regular Expression Format The following operators are required to be accepted: + - one or more of the following character (no groups) * - zero or more of the following character (no groups) [] – no negation,...
1. Write regular expressions to capture the following regular languages: (a) The set of binary strings which have a 1 in every even position. (Note: odd positions may be either 0 or 1.) (b) The set of binary strings that do not contain 011 as a substring. (c) Comments in Pascal. These are delimited by (* and *) or by { and }, and can contain anything in between; they are NOT allowed to nest, however. 2. Write a DFA...
Programming Languages Final Exam Name: Question 1 (15 points) Give a regular expression for each of the following languages over = {0,1,2). 1. All strings that begin with 1 and end with 2. 2. All strings that contain exactly three 1's. For example, "0101012" is valid. 3. All strings in which the digits are non-decreasing. For example, "002" is valid, but "102" is not.
Construct a regular expression that recognizes the following language of strings over the alphabet {0 1}: The language consisting of the set of all bit strings that start with 00 or end with 101 (or both). Syntax The union is expressed as R|R, star as R*, plus as R+, concatenation as RR. Epsilon is not supported but you can write R? for the regex (R|epsilon).
Theory of Computation need ASAP 2-3 hours 1. For the following grammar: a) Give an example of a string accepted by the grammar. b) Give an example of a string not accepted by the grammar. c) Describe the language produced by the grammar. 2. Using the following grammar find a derivation for the string: 0001112 A0A1le C 0C2 | D Create a grammar for the language described by the following RE: Create a grammar for the following language: For the...
Give the regular expressions of the following languages (alphabet is ab): a. {w | w has a length of at least three and its second symbol is a b} b. {w | w begins with an a and ends with a b} c. {w | w contains a single b} d. {w | w contains at least three a's} e. {w | w contains the substring baba} d. {w | w is a string of even length} e. The empty...
For each of the languages listed below, give a regular expression that generates the lan- guage. Briefly justify your answer. (a) The set of strings over (a, b such that any a in the string is followed by an odd number of b's. Examples: bbbab E L, but abb f L. (b) The set of strings over fa, b in which there is an a in every even position and the total number of b's is odd, where the first...
This question deals with NFAs, DFAs, and regular expressions. (a) Using only the symbols described in the lecture slides, write a regular expression that describes all strings over the alphabet Σ = {0,1} that are at are at least four bits long and begin and end with the same bit. (b) Draw a DFA, that accepts strings strings over the alphabet Σ = {0, 1} such that if you read the string from left to right, the difference between the...
Give a CFG that generates the language L(a*b*c*) \ { anbncn | n is a non-negative integer }. This question is quite challenging; you will first need to devise a good strategy for how the CFG should work and then create the CFG to implement the strategy. You might want to do the other questions first. I'm so stuck on this question, can someone pls help me? The following questions ask you to write CFGs. An example illustrates the encoding...
Give a regular expression for each of the following languages. e. {axb | x∈{a, b}*} f. {(ab)n } g. {x ∈ {a, b}* | x contains at least three consecutive as} h. {x ∈ {a, b}* | the substring bab occurs somewhere in x} i. {x ∈ {a, b}* | x starts with at least three consecutive as}