1. Which of the following flags is used to include a newline character \n while using the dot meta character of PHP Regular Expressions?
2. Which of the following PHP Regular Expression modifiers finds one or more occurrences of a specific character in a string?
3. Analyze the following code snippet that uses the preg_last_error() PHP Regular Expression method: < ?php preg_match('/(?:\D+|<\d+>)*[!?]/', 'foobar foobar foobar'); if (preg_last_error() == PREG_BACKTRACK_LIMIT_ERROR) { echo 'Backtrack limit was exhausted!'; } ?> What will be the output of the above code?
4. Suppose you use [hc]+at for pattern matching as a Regular Expression. Which of the following patterns does not match the above expression?
5. What is the [\b] PHP Regular Expression modifier used for?
6. Suppose you pass '^.{3}$' as a pattern to be matched to a specified string using PHP Regular Expressions. Which of the following strings match the above pattern?
7. 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?
8. Analyze the following code: < ?php $string = '1, 100 or 1000?'; preg_match_all('/10*/',$string,$matches); foreach($matches[0] as $value) {echo $value; } ?> What will be the output of the above code snippet?
9. Which of the following PHP Regular Expression modifiers finds zero or one occurrences of a specific character in a string?
10. Analyze the following code: < ?php $str='This lathe turns wood.'; echo(preg_match('/\Bthe\b/', $str)); ?> What will be the output of the above code snippet?
11. Which of the following characters is found by a Regular Expression when the \s PHP modifier is set?
12. Which of the following PHP Regular Expression modifiers is used to make as few matches as possible in a given pattern?
13. Which of the following PHP Regular Expression modifier is used to find a pattern at the beginning of a string?
14. 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?
15. Which of the following is the correct syntax for creating a Regular Expression in PHP?
16. Which of the following characters is used to escape special characters in a given string during pattern matching using Regular Expressions?
17. Analyze the following code snippet that uses the preg_split() PHP Regular Expression method: < ?php $str = 'string'; $chars = preg_split('//', $str, -1, PREG_SPLIT_NO_EMPTY); print_r($chars); ?> What will be the output of the above code?
18. Which of the following characters can be used as a delimiter in a PHP Regular Expression?
19. Analyze the following code snippet that uses the preg_grep() PHP Regular Expression method: < ?php $names = array('Andrew','John','Peter','Nastin','Bill'); $output = preg_grep('/^[a-m]/i', $names); print_r( $output ); ?> What will be the output of the above code?
20. 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?
21. Analyze the following code that uses the ? < = PHP Regular Expression modifier: < ?php $string = 'I live in the whitehouse'; if(preg_match('/(? What will be the output of the above code snippet?
22. 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?
23. Analyze the following code that uses the {x} PHP Regular Expression modifier: < ?php $string = '10 or 100 or 1000?'; preg_match_all('/\d{2}/', $string,$matches); foreach($matches[0] as $value) {echo $value;} ?> What will be the output of the above code snippet?
24. Analyze the following code snippet that uses the preg_match() PHP Regular Expression method: < ?php $string = 'ball'; echo preg_match('/b[aoiu]l/', $string, $matches); ?> What will be the output of the above code?
25. 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?
26. Which of the following PHP Regular Expression modifiers is used to find a pattern at the end of a string?
27. Which of the following is the correct syntax for creating a Regular Expression object in PHP?
28. 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?
29. Analyze the following code snippet that uses the preg_split() PHP Regular Expression method: < ?php $keywords = preg_split('/[\s,]+/', 'php, regular expressions'); print_r( $keywords ); ?> What will be the output of the above code?
30. Analyze the following code: < ?php $string = 'The Lord is the God'; if(preg_match('/the+(?!is)/i', $string,$match)) {print_r($match);} else {echo 'No match found';} ?> What will be the output of the above code snippet?
31. 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?
32. Analyze the following code: < ?php $string = 'six at noon taxes'; echo preg_match('/s.x/', $string, $matches); ?> What will be the output of the above code snippet?
33. Which of the following examples use the PHP positive lookahead assertion in a correct format?
34. Analyze the following code: < ?php $string = '%Give_result%'; preg_match_all('/[\W]/', $string, $matches); foreach($matches[0] as $value) {echo $value;} ?> What will be the output of the above code snippet?
35. Suppose you pass world{2,3} as a pattern to be matched to a specified string as shown in the code snippet below: $pattern = world{2,3}; Which of the following strings does not match the above pattern?
36. 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?
37. Which of the following PHP Regular Expression modifiers finds any non digit character in a given string?
38. Which of the following statements are true about the \b PHP Regular Expression modifier?
39. Analyze the following code snippet that uses the preg_replace() PHP Regular Expression method: What will be the output of the above code snippet?
40. Analyze the following code snippet used to check the password strength: < ?php $password = 'Fyfjk34sdfjfsjq7'; if (preg_match('/^.*(?=.{8,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).*$/', $password)) { echo 'Your passwords is strong.'; } else { echo 'Your password is weak.'; } ?> What will be the output of the above code snippet?
41. Analyze the following code snippet that uses the preg_quote() PHP Regular Expression method: < ?php $keywords = '$40 for a g3/400'; $keywords = preg_quote($keywords, '/'); echo $keywords; ?> What will be the output of the above code?
42. Which of the following characters is not matched by a Regular Expression when a .(dot) character is set?
43. Analyze the following code: < ?php $string = 'The GOD is the Lord.'; $string = preg_replace('/The/g', 'Ze', $string); echo $string; ?> What will be the output of the above code snippet?