Microsoft® JScript™ search Method | Language Reference Version 3

See Also Applies To

##### Description

> Searches a string for matches to a regular expression.

##### Syntax

> stringObj.search(rgexp)

> The search method syntax has these parts:

> Part | Description
> stringObj | Required. The String object or literal to search.
> rgexp | Required. A Regular Expression object containing the pattern to search for.

##### Remarks

> The search method indicates if a match is present or not. If a match is found, the search method returns an integer value that indicates the offset from the beginning of the string where the match occurred. If no match is found, it returns -1. To get further information, use the match method.

> The following example illustrates the use of the search method:

> >     function SearchDemo()
> >     {
> >       var r, re;
> >       var s = "The quick brown fox jumped over the lazy yellow dog.";
> >       re = /fox/i;
> >       r = s.search(re);
> >       return(r);
> >     }

© 1998 Microsoft Corporation. All rights reserved. Terms of Use.