Finds the first sub-string within the passed string which matches the target regular expression
A string against which the regular expression is matched
An optional index with the string at which to start matching
Table — the first match
This method compares the target regular expression against the characters comprising the passed string and returns a table whose keys indicate the location of the first sub-string whose characters match the regular expression.
The table contains just two keys, begin and end, whose values are the indexes delimiting the matched sub-string within the source string. If there is no match, search() returns
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.