var text = "cat bat sat fat"; var pattern = /.at/; var matches = pattern.exec(text); // 패턴 매칭 document.write(matches.input + "<br><br>"); //전달받은 문자열 document.write(matches.index + "<br>"); // 0 에서 찾음 document.write(matches[0] + "<br>"); // cat document.write(pattern.lastIndex + "<br><br>"); // pattern객체의 lastIndex 0 matches = pattern.exec(text); // 패턴 매칭 document.write(matches.index + "<br>"); // 0에서 찾음 document.write(matches[0] + "<br>"); // cat document.write(pattern.lastIndex + "<br><br>"); // lastIndex 0