Home / CSE / PHP - CS :: Regular Expressions

CSE :: PHP - CS

  1. What will be the output if we replace the line $num = preg_grep(“/[0-5]/”, $number); with $num = preg_grep(“/[0-5]/”, $number, PREG_GREP_INVERT);?

  2. A.

     Array([0]=>0 [1]=>1 [2]=>two [3]=>three [4]=>four [5]=>5)

    B.

     Array([2]=>two [3]=>three [4]=>four)

    C.

     Array([1]=> 1)

    D.

     Array([0]=>0 [5]=>5)

    View Answer

    Workspace

    Discuss Discuss in Forum


  3. Which one of the following functions is used to search a string?

  4. A.

     preg_match

    B.

     preg_search

    C.

     preg_find

    D.

     preg_found

    View Answer

    Workspace

    Discuss Discuss in Forum


  5. What will be the output of the following PHP code?

    <?php

    $name = "What is your name?"

    if (preg_match("/name/"),$name)

    echo "My name is Will Pitt ";

    else

    echo "My name is not Will Pitt ";

    if (preg_match("/are/"))

    echo "I am great"

    else

    echo "I am not great";

    ?>

  6. A.

     My name is Will Pitt I am great

    B.

     My name is not Will Pitt I am great

    C.

     My name is Will Pitt I am not great

    D.

     My name is not Will Pitt I am not great

    View Answer

    Workspace

    Discuss Discuss in Forum


  7. Which one of the following preg PHP function is used to do a find and replace on a string or an array?

  8. A.

     preg_replace()

    B.

     preg_find()

    C.

     preg_find_replace()

    D.

     preg_findre()

    View Answer

    Workspace

    Discuss Discuss in Forum


  9. What will be the output of the following PHP code?

    <?php

    $str = "Hello! My name is Cameron Fox. Coffee?"

    $find = array('/is/','/coffee/');

    $replace = array('/was/','/tea/');

    echo preg_replace ($find, $replace, $str);

    ?>

  10. A.

     Hello! My name was Cameron Fox. tea?

    B.

     Hello! My name is Cameron Fox. tea?

    C.

     Hello! My name is Cameron Fox. Coffee?

    D.

     Hello! My name was Cameron Fox. Coffee?

    View Answer

    Workspace

    Discuss Discuss in Forum


  11. Which one of the following preg PHP functions is used to take a string, and put it in an array?

  12. A.

     preg_destroy()

    B.

     preg_split()

    C.

     preg_unchain()

    D.

     preg_divide()

    View Answer

    Workspace

    Discuss Discuss in Forum


  13. What will be the output of the following PHP code?

    <?php

    $line = "You like dogs. I hate dogs. We should marry."

    $sen = preg_split('/./', $line);

    print_r($sen);

    ?>

  14. A.

     You like dogs. I hate dogs. We should marry.

    B.

     Array([0]=>You like dogs. I hate dogs. We should marry.)

    C.

     Array([0]=>You like dogs. [1]=>I hate dogs. [2]=>We should marry.)

    D.

     Error

    View Answer

    Workspace

    Discuss Discuss in Forum


  15. Which one of the following is not a preg PHP function?

  16. A.

     preg_match

    B.

     preg_match_all

    C.

     preg_matchall

    D.

     preg_split

    View Answer

    Workspace

    Discuss Discuss in Forum


  17. Parameter flags was added in which version of PHP?

  18. A.

     PHP 4.0

    B.

     PHP 4.1

    C.

     PHP 4.2

    D.

     PHP 4.3

    View Answer

    Workspace

    Discuss Discuss in Forum