Home > MCQs > IT & Programming > Regular Expressions With PHP Test MCQs

Regular Expressions With PHP Test MCQ

Quizack brings the ultimate solution for your upcoming assessments in the form of Regular Expressions with PHP MCQs. Subject matter experts have chosen topics from top reference books, international testing patterns, and ongoing practical techniques. Eventually, Quizack brings a wide range of topics through its Regular Expressions with PHP multiple choice questions. It will excite you more, you can practice all these MCQs via online simulations. 

 

Regular Expressions With PHP Test Quick Quiz

Question 1 of 10
  • Which of the following PHP Regular Expression modifiers finds one or more occurrences of a specific character in a string?


    Answer & Explanation

    Correct Answer: +

    Note: This Question is unanswered, help us to find answer for this one

  • Analyze the following code:

    <?php
    $string = 'This is a [templateVar]';
    preg_match_all("/[\[\]]/", $string, $matches);
    foreach($matches[0] as $value)
            {
            echo $value;
            }
    ?>

    What will be the output of the above code snippet?


    Answer & Explanation

    Correct Answer: []

    Note: This Question is unanswered, help us to find answer for this one

  • Suppose you pass "a(bc)*" as a pattern to be matched to a specified string using PHP Regular Expressions. Which of the following strings does not match the above pattern?


    Answer & Explanation

    Correct Answer: bcde

    Note: This Question is unanswered, help us to find answer for this one

  • Which of the following is the correct syntax for creating a Regular Expression in PHP?


    Answer & Explanation

    Correct Answer: preg_match("/^ABC/i", $string)

    Note: This Question is unanswered, help us to find answer for this one

  • Analyze the following code that uses a PHP Regular Expression Character Set:

    <?php
    $string = "Is this all there is?";
    preg_match_all("/[a-h]/",$string,$matches);
    foreach($matches[0] as $value)
            {
            echo $value;
            }
    ?>

    What will be the output of the above code snippet?


    Answer & Explanation

    Correct Answer: hahee

    Note: This Question is unanswered, help us to find answer for this one

  • Suppose you perform pattern matching in a string using the \n PHP Regular Expression modifier. Which of the following values is returned if no newline character occurs in the string?


    Answer & Explanation

    Correct Answer: 0

    Note: This Question is unanswered, help us to find answer for this one

  • Analyze the following code snippet that uses the preg_replace() PHP Regular Expression method:

    <?php
    $string = 'This is the {_FOO_} brought to you by {_BAR_}';
    $template_vars=array("FOO" => "The PHP Way", "BAR" => "PHPro.orG");
    $string = preg_replace("/{_(.*?)_}/ime", "\$template_vars['$1']",$string);
    echo $string;
    ?>

    What will be the output of the above code?


    Answer & Explanation

    Correct Answer: This is the The PHP Way brought to you by PHPro.orG

    Note: This Question is unanswered, help us to find answer for this one

  • Analyze the following code that uses a PHP Regular Expression Character Set:

    <?php
    $string = "Welcome to the new era";
    preg_match_all("/[h-b]/",$string,$matches);
    foreach($matches[0] as $value)
            {
            echo $value;
            }
    ?>

    What will be the output of the above code snippet?


    Answer & Explanation

    Correct Answer: Compilation error will be displayed.

    Note: This Question is unanswered, help us to find answer for this one

  • Analyze the following code that uses a PHP Regular Expression Character Set:

    <?php
    $string = "Is this all there is?";
    echo(preg_match("/[^A-J]/",$string,$matches));
    ?>

    What will be the output of the above code snippet?


    Answer & Explanation

    Correct Answer: 1

    Note: This Question is unanswered, help us to find answer for this one

  • Which of the following PHP Regular Expression modifiers is used to put the Regex on multiple lines while at the same time allowing comments within the Regular Expression itself?


    Answer & Explanation

    Correct Answer: x

    Note: This Question is unanswered, help us to find answer for this one

  • Regular Expressions With PHP Test Quick Quiz

    battery

    Poor Results!

    You need a lot of improvement.

    Just don't give up!

    Correct Answers: 0/10

    Start Practicing with our MCQs given below.