Skip to main content, startIndex)

Finds the first sub-string within the passed string which matches the target regular expression


Device + Agent


Name Type Description
comparisonString String A string against which the regular expression is matched
startIndex Integer An optional index with the string at which to start matching


Table — the first match, otherwise null


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.

Important Because of shortcomings in Squirrel’s regexp, we strongly recommend that you implement regular expressions in your agent code using as a drop-in replacement for

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 null.

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.

Example Code