Finds and tabulates sub-strings which match the target regular expression
Device + Agent
A string against which the regular expression is matched
An optional character index within the string at which to start matching
Array — the captured sub-strings each in tabular form
This method compares the target regular expression against the characters comprising the passed string and returns an array of tables, each of which indicates the location of a sub-string whose characters match the regular expression.
Each table contains just two keys, begin and end, whose values are the indexes delimiting the sub-string within the main string. The array will contain as many tables as there are matches. If there are no matches, capture() returns
null not an empty array.
A second, optional parameter may be passed to the method: the index within the passed string at which to begin the search for pattern matches. If this parameter is not provided, the search commences at the start of the string.
Compare this method with search() which returns only the first of the matched sub-strings found within the source string.