PrepAway - Latest Free Exam Questions & Answers

How many elements does the $matches array contain after the following function call is performed? preg_match(&

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

PrepAway - Latest Free Exam Questions & Answers

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(&

  1. ruslanbes says:

    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

Leave a Reply

Your email address will not be published. Required fields are marked *