RegExp.lastIndex
マッチした最後の開始位置を得る
構文
RegExp.lastIndex
例文
<html>
<head>
<title>RegExp.lastIndex</title>
</head>
<body>
<!--マッチした最後の開始位置を得るのサンプル-->
<script type="text/javascript">
var str = "ABCDEFG";
var rex = new RegExp("(B.+F)", "i");
if (str.match(rex)) {
document.write(RegExp.lastIndex+"文字目〜マッチしました。");
} else {
document.write("マッチしません。");
}
</script>
</body>
</html>
関連記事
- RegExp.$1〜$9
- RegExp
- String.match
- RegExp.rightContext
- RegExp.leftContext
- RegExp.lastParen
- RegExp.lastMatch
- RegExp.index
- RegExp.$n
スポンサーリンク





