Vidyalelo
PHP · all questions

Regular Expressions
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

30

Questions

1/2

Page

Pick an option on a question to see the right answer and solution.

PHP has long supported two regular expression implementations known as _______ and _______.
1. Perl
2. PEAR
3. Pearl
4. POSIX

Select an option to see the answer and solution.

Which one of the following regular expression matches any string containing zero or one p?

Select an option to see the answer and solution.

[:alpha:] can also be specified as.

Select an option to see the answer and solution.

How many functions does PHP offer for searching strings using POSIX style regular expression?

Select an option to see the answer and solution.

What will be the output of the following PHP code?
<?php
$username = "jasoN";
if (ereg("([^a-z])",$username))
  echo "Username must be all lowercase!";
else
  echo "Username is all lowercase!";
?>

Select an option to see the answer and solution.

POSIX implementation was deprecated in which version of PHP?

Select an option to see the answer and solution.

POSIX stands for

Select an option to see the answer and solution.

What will be the output of the following PHP code?
<?php
$text = "this istsome text thatnwe might like to parse.";
print_r(split("[nt]",$text));
?>

Select an option to see the answer and solution.

Which of the following would be a potential match for the Perl-based regular expression /fo{2,4}/ ?
1. fol
2. fool
3. fooool
4. fooooool

Select an option to see the answer and solution.

Which among the following is/are not a metacharacter?
1. /a
2. /A
3. /b
4. /B

Select an option to see the answer and solution.

How many functions does PHP offer for searching and modifying strings using Perl-compatible regular expressions.

Select an option to see the answer and solution.

What will be the output of the following PHP code?
<?php
$foods = array("pasta", "steak", "fish", "potatoes");
foods);
print_r($food);
?>

Select an option to see the answer and solution.

Say we have two compare two strings which of the following function/functions can you use?
1. strcmp()
2. strcasecmp()
3. strspn()
4. strcspn()

Select an option to see the answer and solution.

Which one of the following functions will convert a string to all uppercase?

Select an option to see the answer and solution.

What will be the output of the following PHP code?
<?php
$title = "O'malley wins the heavyweight championship!";
echo ucwords($title);
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code?
<?php
echo str_pad("Salad", 5)." is good.";
?>

Select an option to see the answer and solution.

Which one of the following functions can be used to concatenate array elements to form a single delimited string?

Select an option to see the answer and solution.

Which one of the following functions finds the last occurrence of a string, returning its numerical position?

Select an option to see the answer and solution.

What will be the output of the following PHP code?
<?php
$author = "[email protected]";
author);
echo "Contact the author of this article at $author.";
?>

Select an option to see the answer and solution.