// checks for the pattern "xyz" in str. If found, then
// output written to document indicating that it was found and
// displays the index it was found in the string.
myRe=/xyz*/g;
str = "abcxyzdefhij"
myArray = myRe.exec(str);
document.writeln("Found " + myArray[0] + " in the pattern: " + "" +
"abcxyzdefhij " + "" + " at index " +
(myRe.lastIndex - 3));
// End Hide -->