Web Designing MCQs

Top 20 MCQ Questions on Perl Regular Expressions in PHP

Google+ Pinterest LinkedIn Tumblr
Here are the collections of top 20 MCQ questions on Perl regular expressions in PHP includes multiple-choice questions on PHP’s Perl based regular expression. It includes MCQ questions on different types of quantifiers, modifiers, and metacharacters used on Perl based regular expressions. It also includes objective questions on different functions available in Perl compatible regular expressions.

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

  1. B. X
  2. C. U
  3. D. M
  4. A. i-True, ii-False
  5. C. i and iii only
  6. B. \W
  7. A. \w
  8. C. eight
  9. A. preg_grep()
  10. B. preg_match()
  11. D. preg_quote()
  12. B. /mb\b/
  13. C. i-Ture, ii-True, iii-False
  14. A. S
  15. B. /en+/
  16. A. /\bperl\b/i
  17. B. string preg_quote(string str [, string delimeter])
  18. A. preg_replace()
  19. D. i-True, ii-True
  20. A. preg_filter()

Read Next: Top 20 MCQ Questions on Handling Strings in PHP

Shuseel Baral is a web programmer and the founder of InfoTechSite has over 8 years of experience in software development, internet, SEO, blogging and marketing digital products and services is passionate about exceeding your expectations.

Write A Comment