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>

関連記事

スポンサーリンク

CURRENT_DATE関数 現在の日付を求める

ホームページ製作・web系アプリ系の製作案件募集中です。

上に戻る