文字から文字を抜き出すsubstring()の基本

string.substring(indexA,indexB)の形式で使用。
indexA、indexBのうち、小さいインデックス番号と
大きいインデックス番号の間の文字を抜き出す。
ただし、大きい値のインデックス番号の文字は抜き出す文字に含まれない。
大きい値のインデックス番号の1つ前の文字までが抜き出される。
indexAとindexBはどちらが大きくても可。
stringのインデックス番号は0から始まる。
実行結果


ヘッダ部分
なし

ボディ部分 <SCRIPT LANGUAGE="JavaScript"> var str = "This is my HOMEPAGE" document.write(str.substring(0,10) + "<BR>") document.write(str.substring(0,0) + "<BR>") document.write(str.substring(0,1) + "<BR>") document.write(str.substring(1,2) + "<BR>") document.write(str.substring(1,3) + "<BR>") document.write(str.substring(1,8) + "<BR>") document.write(str.substring(1,1) + "<BR>") document.write(str.substring(0,4) + "<BR>") document.write(str.substring(4,0) + "<BR>") document.write(str.substring(4,100) + "<BR>") </SCRIPT>