250+ TOP MCQs on Regular Expression and Answers

Compilers Multiple Choice Questions on “Regular Expression”.

1. A regular expression enables a quick test to determine objects and text strings with undependable values.
a) True
b) False

Answer: a
Clarification: Because it checks for all the values and determines whether the output string matches with the given string.

2. RE can be used only for values of type string and number.
a) True
b) False

Answer: b
Clarification: No not for all values the string and numbers can we use the RE.

3. You can use RE, if you expect the value of a property to change in an unpredictable way each time its run.
a) True
b) False

Answer: b
Clarification: For every cycle the values does not change unpredictably because the type of grammar that it accepts is defined.

4. All ___________ are automatically treated as regular expressions.
a) Programmatic description
b) Window
c) Win Object
d) Collection

Answer: a
Clarification: The programmatic description is genuinely treated as regular expression.

5. If a ‘/’ is used before a character that has no special meaning, ‘/’ is ignored.
a) True
b) False

Answer: a
Clarification: The backslash carries no significance and it is ignored.

6. The regular expression denotes a language comprising all possible strings of even length over the alphabet (0, 1).
a) 1 + 0(1+0)*
b) (0+1) (1+0)*
c) (1+0)
d) (00+0111+10)*

Answer: d
Clarification: Option 1 + 0(1+0)* → It does not consider even length criteria for the question.
Option (0+1) (1+0)* → It can so happen here that from the former bracket it takes 0 or 1 and takes null from the latter then it forms a string of odd length
Option (1+0) → It gives either 1 or 0.
Hence Option (00+0111+10)* is the answer.

7. The RE gives none or many instances of an x or y is?
a) (x+y)
b) (x+y)*
c) (x* + y)
d) (xy)*

Answer: b
Clarification: Whether x or y is denoted by x+y and for zero or more instances it is denoted but (x+y)*.

Leave a Reply

Your email address will not be published. Required fields are marked *