ExamVeda
Login
Home
1
PHP has long supported two regular expression implementations known as _______ and _______.
1. Perl
2. PEAR
3. Pearl
4. POSIX
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
2
Which one of the following regular expression matches any string containing zero or one p?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
3
[:alpha:] can also be specified as.
Discuss
Answer & Solution
Answer: Option B
Solution:
[:alpha:] is nothing but Lowercase and uppercase alphabetical characters.
4
How many functions does PHP offer for searching strings using POSIX style regular expression?
Discuss
Answer & Solution
Answer: Option A
Solution:
ereg(), ereg_replace(), eregi(), eregi_replace(), split(), spliti(), and sql_regcase() are the functions offered.
5
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!";
?>
Discuss
Answer & Solution
Answer: Option B
Solution:
Because the provided username is not all lowercase, ereg() will not return FALSE (instead returning the length of the matched string, which PHP will treat as TRUE), causing the message to output.
6
POSIX implementation was deprecated in which version of PHP?
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
7
POSIX stands for
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
8
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));
?>
Discuss
Answer & Solution
Answer: Option D
Solution:
The split() function divides a string into various elements, with the boundaries of each element based on the occurrence of a defined pattern within the string.
9
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
Discuss
Answer & Solution
Answer: Option B
Solution:
This matches f followed by two to four occurrences of o.
10
Which among the following is/are not a metacharacter?
1. /a
2. /A
3. /b
4. /B
Discuss
Answer & Solution
Answer: Option A
Solution:
/A, /b and /B are metacharacters. A: Matches only at the beginning of the string. b: Matches a word boundary. B: Matches anything but a word boundary.