Home / CSE / PHP - CS :: Regular Expressions

CSE :: PHP - CS

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

  2. A.

     1 and 2

    B.

     2 and 4

    C.

     1 and 4

    D.

     2 and 3


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

  4. A.

     p+

    B.

     p*

    C.

     P?

    D.

     p#


  5. [:alpha:] can also be specified as.

  6. A.

     [A-Za-z0-9]

    B.

     [A-za-z]

    C.

     [A-z]

    D.

     [a-z]


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

  8. A.

     7

    B.

     8

    C.

     9

    D.

     10


  9. 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!";

    ?>

  10. A.

     Error

    B.

     Username must be all lowercase!

    C.

     Username is all lowercase!

    D.

     No Output is returned


  11. POSIX implementation was deprecated in which version of PHP?

  12. A.

     PHP 4

    B.

     PHP 5

    C.

     PHP 5.2

    D.

     PHP 5.3


  13. POSIX stands for

  14. A.

     Portable Operating System Interface for Unix

    B.

     Portable Operating System Interface for Linux

    C.

     Portative Operating System Interface for Unix

    D.

     Portative Operating System Interface for Linux


  15. 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));

    ?>

  16. A.

     this is some text that we might like to parse.

    B.

     Array ( [0] => some text that [1] => we might like to parse. )

    C.

     Array ( [0] => this is [1] => some text that [2] => we might like to parse. )

    D.

     [0] => this is [1] => some text that [2] => we might like to parse.


  17. 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

  18. A.

     Only 1

    B.

     2 and 3

    C.

     1, 3 and 4

    D.

     1 and 4


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

  20. A.

     Only 1

    B.

     1 and 3

    C.

     2, 3 and 4

    D.

     2 and 4