Question

Write a regular expression that generates each of the following language constructs: (1) String constants with...

Write a regular expression that generates each of the following language constructs:
(1) String constants with the following specifications:
A string constant consists of any sequence of characters enclosed by the quotation marks: “ and ”
The sequence may be empty.​
The sequence cannot span multiple lines.
Don’t worry about escape characters (assume that they won’t appear in the input).
(2) Multiple-line comment in C, C++ and JAVA with the following specifications:
The comment consists of any sequence of characters enclosed by the delimiters /* and */.
The sequence may be empty.
The sequence cannot have the * character.
Don’t worry about escape characters (assume that they won’t appear in the input).

Homework Answers

Answer #1

1. \".*\"

Explanation: Here \" is for " character . is for any character except new line, * is for zero or more so .* means zero or more characters (multiple characters means string)

2. \/\*(.|\n)*\*\/

Explanation: Here \/ is for / character \* is for * character (.|\n) is for any character or linebreak and * is for zero or more so (.|\n)* means zero or more characters including linebreak

If you are directly copieng the regex it may not work since it has color and that color may include a hidden character into the current regex,so please try to type it instead of copy paste,Here is the two answers without any color/bold

1) \".*\"

2) \/\*(.|\n)*\*\/

PS-: If you have any problems/doubts please comment below.Thank you

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Question 4 Write a regular expression that generates each of the following language constructs: (1) String...
Question 4 Write a regular expression that generates each of the following language constructs: (1) String constants with the following specifications: A string constant consists of any sequence of characters enclosed by the quotation marks: “ and ”       The sequence may be empty.                    The sequence cannot span multiple lines.       Don’t worry about escape characters (assume that they won’t appear in the input).       (2)  Multiple-line comment in C, C++ and JAVA with the following specifications:        The comment consists of any sequence...
Write the regular expression that will match the following string pattern descriptions. A space character at...
Write the regular expression that will match the following string pattern descriptions. A space character at the beginning of a line Upper case vowel one and more lines with a length of exactly 80 characters A single character that cannot be an alpha or a digit A dollar sign character ‘$’ at the end of the line
Note: Do not use classes or any variables of type string to complete this assignment Write...
Note: Do not use classes or any variables of type string to complete this assignment Write a program that reads in a sequence of characters entered by the user and terminated by a period ('.'). Your program should allow the user to enter multiple lines of input by pressing the enter key at the end of each line. The program should print out a frequency table, sorted in decreasing order by number of occurences, listing each letter that ocurred along...
JAVA ASSIGNMENT 1. Write program that opens the file and process its contents. Each lines in...
JAVA ASSIGNMENT 1. Write program that opens the file and process its contents. Each lines in the file contains seven numbers,which are the sales number for one week. The numbers are separated by comma.The following line is an example from the file 2541.36,2965.88,1965.32,1845.23,7021.11,9652.74,1469.36. The program should display the following: . The total sales for each week . The average daily sales for each week . The total sales for all of the weeks .The average weekly sales .The week number...
You will write a program that loops until the user selects 0 to exit. In the...
You will write a program that loops until the user selects 0 to exit. In the loop the user interactively selects a menu choice to compress or decompress a file. There are three menu options: Option 0: allows the user to exit the program. Option 1: allows the user to compress the specified input file and store the result in an output file. Option 2: allows the user to decompress the specified input file and store the result in an...
Write a program of wordSearch puzzle that use the following text file as an input. The...
Write a program of wordSearch puzzle that use the following text file as an input. The output should be like this: PIXEL found (left) at (0,9). ( Use JAVA Array ) .Please do not use arrylist and the likes! Hints • The puzzle can be represented as a right-sized two-dimensional array of characters (char). • A String can be converted into a right-sized array of characters via the String method toCharArray. . A word can occur in any of 8...
This laboratory assignment involves implementing a data structure called a map. A map associates objects called...
This laboratory assignment involves implementing a data structure called a map. A map associates objects called keys with other objects called values. It is implemented as a Java class that uses arrays internally. 1. Theory. A map is a set of key-value pairs. Each key is said to be associated with its corresponding value, so there is at most one pair in the set with a given key. You can perform the following operations on maps. You can test if...