Finds the first match against the target regular expression and tabulates group captures within the match
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 matched sub-string and each group capture in tabular form
This method compares the target regular expression against the characters comprising the passed string and returns an array of tables which indicate the first location of a sub-string whose characters match the regular expression and then any capture group matches within that sub-string.
If there is no match, capture() returns
null not an empty array. If there is a match, but there no capture group matches within the sub-string (or no groups in the regular expression), only the matched sub-string is included in the array.
Each table contains just two keys, begin and end, whose values are the indexes delimiting the sub-string within the main string.
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. You can use this to iterate through the comparison string to find multiple matches against the target regular expression.