String.replace

文字列置換を行う

構文

stringObject.replace(find,string)

引数

find=検索文字列, string=置換文字列

例文

<html>
<head>
<title>String.replace</title>
</head>

<body>

<!--文字列置換を行うのサンプル-->
<script type="text/javascript">
var str="String Hello"
document.write(str.replace("String", "Spring") + "<br>");
document.write(str.replace(/H.+o/i, "mojiretu") + "<br>");
document.write(str.replace(/S.+H/i, "M"));
</script>

</body>
</html>

関連記事

スポンサーリンク

閲覧領域のスクロールバーのスタイルをbody要素で指定しなければならない

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

上に戻る