Read Next: Top 20 MCQ Questions on POSIX Regular Expressions in PHP
1) … is the modifier of Perl based regular expression in PHP which will ignore white space and comments within the regular expression.
A. S
B. X
C. U
D. M
2) … is the modifier of Perl based regular expression in PHP which will match the pattern as many times as possible rather than just stop the first match.
A. S
B. X
C. U
D. M
3) The modifier… will allow for ^ and $ to match at the beginning of any line in a string.
A. S
B. X
C. U
D. M
4) State, whether the following statements about the modifiers of Perl-based regular expressions are TRUE or FALSE.
i. The modifier I will perform a case-insensitive search.
ii.The modifier S will perform a case-sensitive search.
A. i-True, ii-False
B. i-False, ii-True
C. i-False, ii-False
D. i-True, ii-True
5) State, whether the following statements about metacharacters of Perl-based regular expressions are TRUE.
i. \A matches only at the beginning of the string.
ii. \b matches anything but a word boundary.
iii. \d matches a digit character.
A. i and ii only
B. ii and iii only
C. i and iii only
D. All i, ii and iii
6) The metacharacter … will matches a string, omitting the underscore and alphanumeric characters.
A. \w
B. \W
C. \M
D. \N
7) The metacharacter … in Perl based regular expression is the same as [a-zA-Z0-9].
A. \w
B. \W
C. \M
D. \N
8) PHP offers … functions for searching and modifying strings using Perl compatible regular expressions.
A. six
B. seven
C. eight
D. nine
9) The … function searches all elements of an array, returning an array consisting of all elements matching a certain pattern.
A. preg_grep()
B. preg_match()
C. preg_match_all()
D. preg_filter()
10) The … function searches a string for a specific pattern, returning TRUE if it exists and FALSE otherwise.
A. preg_grep()
B. preg_match()
C. preg_match_all()
D. preg_filter()
11) The … function searches a string for a specific pattern, returning TRUE if it exists and FALSE otherwise.
A. preg_grep()
B. preg_match()
C. preg_match_all()
D. preg_filter()
11) The … function inserts a backslash delimiter before every character of special significance to regular expression syntax.
A. preg_replace()
B. preg_match()
C. preg_match_all()
D. preg_quote()
12) The regular expression will match strings such as ‘limb’ and ‘timb’ but not ‘mbbs’.
A. /mb\B/
B. /mb\b/
C. /mb\A/
D. /mb\d/
13) State, whether the following statements about metacharacters in regular expressions are TRUE or FALSE.
i. $ matches the end of a line.
ii. / quotes the next metacharacter.
iii. [] encloses a character grouping.
A. i-True, ii-False, iii-True
B. i-True, ii-True, iii-True
C. i-Ture, ii-True, iii-False
D. i-False, ii-Ture, iii-False
14) … is the modifier of Perl based regular expression in PHP which treats the string as a single line, ignore any newline characters found within.
A. S
B. X
C. N
D. M
15) … will match en, whether the string appears in isolation or is followed by one or more characters.
A. /en/
B. /en+/
C. /en*/
D. /en{1}/
16) The regular expression … returns the first case-insensitive occurance of the word ‘perl’.
A. /\bperl\b/i
B. /perl/i
C. /perl\b/i
D. /\Bperl\B/i
17) Which of the following is the correct syntax of using the function preg_quote().
A. string preg_quote(string pattern, string str [, string delimeter])
B. string preg_quote(string str [, string delimeter])
C. string preg_quote(mixed str [, string delimeter])
D. string preg_quote(string pattern [, string delimeter])
18) The … functions replaces all occurrences of pattern with replacement and returns the modified result.
A. preg_replace()
B. preg_replace_all()
C. preg_replace_callback()
D. pret_replace_pattern()
19) State, whether the following statements about splitting a string into various elements are TRUE or FALSE.
i. The preg_split() function operates exactly like split().
ii. In preg_split() function, the pattern can also be defined in terms of the regular expression.
A. i-True, ii-False
B. i-False, ii-True
C. i-False, ii-False
D. i-True, ii-True
20) The … function operates in a fashion identical to the preg_replace() function, except that, rather than returning a modified result, only matches are returned.
A. preg_filter()
B. preg_replace_all()
C. preg_replace_callback()
D. pret_replace_pattern()
Answers
- B. X
- C. U
- D. M
- A. i-True, ii-False
- C. i and iii only
- B. \W
- A. \w
- C. eight
- A. preg_grep()
- B. preg_match()
- D. preg_quote()
- B. /mb\b/
- C. i-Ture, ii-True, iii-False
- A. S
- B. /en+/
- A. /\bperl\b/i
- B. string preg_quote(string str [, string delimeter])
- A. preg_replace()
- D. i-True, ii-True
- A. preg_filter()
Read Next: Top 20 MCQ Questions on Handling Strings in PHP