How many elements does the $matches array contain after the following function call is performed? preg_match(‘/^(\d{1,2}([a-z]+))(?:\s*)\S+ (?=201[0-9])/’, ’21st March 2014′, $matches);
A. 1
B. 2
C. 3
D. 4
Explanation:
One Comment on “How many elements does the $matches array contain after the following function call is performed? preg_match(&”
ruslanbessays:
This is probably the hardest question to explain. To get the right answer you should count the number of subpatterns in round brackets and add +1 for the ‘whole expression match’. You should however exclude those subpatterns which begin with (?: and (?= since this is a special syntax telling that these subpatterns should no be added into final matches.
This is probably the hardest question to explain. To get the right answer you should count the number of subpatterns in round brackets and add +1 for the ‘whole expression match’. You should however exclude those subpatterns which begin with (?: and (?= since this is a special syntax telling that these subpatterns should no be added into final matches.
0
0