Php Regular Expressions(Engineering > Computer Science And Engineering > Php ) Questions and Answers
Question 1. PHP has long supported two regular expression implementations known as _______ and _______.1. Perl2. PEAR3. Pearl4. POSIX
1 and 2
2 and 4
1 and 4
2 and 3
Explanation:-
Answer: Option C. -> 1 and 4
Question 2. Which one of the following regular expression matches any string containing zero or one p?
P?
p+
p#
p*
Explanation:-
Answer: Option A. -> P?
Question 3. How many functions does PHP offer for searching strings using POSIX style regular expression?
8
10
9
7
Explanation:-
Answer: Option D. -> 7
Question 4. [:alpha:] can also be specified as.
[A-z]
[a-z]
[A-Za-z0-9]
[A-za-z]
Explanation:-
Answer: Option D. -> [A-za-z]
Question 5. What will be the output of the following PHP code?$username = "jasoN";if (ereg("([^a-z])",$username))echo "Username must be all lowercase!";elseecho "Username is all lowercase!";
Error
Username is all lowercase!
No Output is returned
Username must be all lowercase!
Explanation:-
Answer: Option D. -> Username must be all lowercase!
Question 6. POSIX stands for
Portative Operating System Interface for Unix
Portable Operating System Interface for Linux
Portative Operating System Interface for Linux
Portable Operating System Interface for Unix
Explanation:-
Answer: Option D. -> Portable Operating System Interface for Unix
Question 7. Which among the following is/are not a metacharacter?1. /a2. /A3. /b4. /B
2, 3 and 4
2 and 4
1 and 3
Only 1
Explanation:-
Answer: Option D. -> Only 1
Question 8. Which of the following would be a potential match for the Perl-based regular expression /fo{2,4}/ ?1. fol2. fool3. fooool4. fooooool
Only 1
1 and 4
1, 3 and 4
2 and 3
Explanation:-
Answer: Option D. -> 2 and 3
Question 9. What will be the output of the following PHP code?$text = "this istsome text thatnwe might like to parse.";print_r(split("[nt]",$text));
this is some text that we might like to parse.
Array ( [0] => some text that [1] => we might like to parse. )
Array ( [0] => this is [1] => some text that [2] => we might like to parse. )
[0] => this is [1] => some text that [2] => we might like to parse.
Explanation:-
Answer: Option D. -> [0] => this is [1] => some text that [2] => we might like to parse.
Question 10. POSIX implementation was deprecated in which version of PHP?