[javascript] 行末の半角スペース|全角スペースを削除する正規表現

サンプル

行末の全角 or 半角のスペースを削除

ソース

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript">
function tikan(){

 hogera01 = document.frm.bar01.value
 hogera02 = new RegExp(/ | $/gm);
 hogera03 = hogera01.replace(hogera02, "");
 
 document.frm.result.value = hogera03;
}
</script>
<form name="frm">
<div><textarea type="text" name="bar01" class="tikan_tool"></textarea></div>
<div><input type="button" onclick="tikan()" value="タグ置換" style="margin:10px 0; padding:6px 20px;"></div>
<div><textarea name="result" class="tikan_tool"></textarea></div>
</form>

カテゴリ:

トラックバック(0)

トラックバックURL: http://www.0yen-coding.com/mt-tb.cgi/95

コメントする

あわせて読みたいブログパーツ