It also includes objective type questions on different PHP’s regular expression functions for performing case-sensitive and case-insensitive search along with splitting the string into various elements based on case sensitive and case-insensitive patterns.
Read Also: Top 20 MCQ Questions on Exception Handling in PHP
1) The POSIX implementation of regular expression was deprecated in the PHP version…
A. 5.2
B. 5.3
C. 5.4
D. 6
2) State whether the following statements about regular expression are TRUE or FALSE.
i. A regular expression is nothing more than a pattern of characters itself that was matched against a certain parcel of text.
ii. It may be a pattern with which you are already familiar or it may be a pattern with specific meaning in the context of the word of pattern matching.
A. i-True, ii-False
B. i-False, ii-True
C. i-False, ii-False
D. i-True, ii-True
3) … are used to represent a list or range of characters to be matched.
A. []
B. {}
C. ()
D. /*
4) In PHP’s regular expression, … matches any string containing at least one a.
A. a*
B. a
C. a+
D. a{1}
5) The regular expression, … matches any string containing zero or more a’s.
A. a*
B. a
C. a+
D. a{1}
6) The regular expression, … matches any string containing zero or one a.
A. a*
B. a
C. a+
D. a?
7) The … matches any string not containing any of the characters ranging from a through z and A through Z.
A. [a-zA-Z]
B. {^a-zA-Z}
C. [^a-zA-Z]
D. [^a-z-A-Z]
8) … matches any string containing a ‘b’ followed by zero or more instances of the sequence of ‘ag’.
A. b[ag]
B. b(ag)+
C. b(ag)
D. b(ag)*
9) … matches any string inclosed within <i> and </i>.
A. <i>(.*)</i>
B. <i>[.*]</i>
C. <i>(.?)</i>
D. <i>[*]</i>
10) The predefined character class … specifies the lowercase and uppercase alphabetical characters and numeric digits.
A. [:alpha:]
B. [:graph:]
C. [:alnum:]
D. [:num:]
11) The predefined default character class … can also be specified as [A-Za-z].
A. [:alpha:]
B. [:graph:]
C. [:alnum:]
D. [:num:]
12) The predefined default character class … specifies printable characters found in the range of ASCII 33 to 126.
A. [:alpha:]
B. [:graph:]
C. [:alnum:]
D. [:char:]
13) PHP offers …. functions for searching strings using POSIX style regular expressions.
A. five
B. six
C. seven
D. eight
14) The PHP’s regular expression function, … executes a case-sensitive search of string for a defined pattern.
A. eregi()
B. ereg()
C. regi()
D. regse()
15) You can perform case insensitive search with the function … in PHP’s regular expression.
A. eregi()
B. ereg()
C. regi()
D. regse()
16) The … function will be useful when checking the validity of strings, such as passwords.
A. eregi()
B. ereg()
C. regi()
D. regse()
17) The … function will split a string into various elements based on case insensitive pattern.
A. eregi()
B. ereg()
C. split()
D. spliti()
18) The … function converts each character in a string into a bracketed expression containing two characters.
A. eregi()
B. eregcase()
C. sql_regcase()
D. regcase()
19) The predefined character class … will specify whitespace characters, including space, horizontal tab, vertical tab, newline, form feed, or carriage return.
A. [:tab:]
B. [:space:]
C. [:whitespace:]
D. [:char:]
20) The regular expression … will match any string containing exactly three characters.
A. ^.{3}$
B. ^.{3}
C. {3}$
D. *{3}$
Answers
- B. 5.3
- D. i-True, ii-True
- A. []
- C. a+
- A. a*
- D. a?
- C. [^a-zA-Z]
- D. b(ag)*
- A. <i>(.*)</i>
- C. [:alnum:]
- A. [:alpha:]
- B. [:graph:]
- C. seven
- B. ereg()
- A. eregi()
- A. eregi()
- D. spliti()
- C. sql_regcase()
- B. [:space:]
- A. ^.{3}$
Read Next: Top 20 MCQ Questions on Perl Regular Expressions in PHP
Comments are closed.