본문 바로가기

js/jQuery

[javascript] substring 문자열 자르기



 
 
HTML
 
<div id="result"></div>
 
javascript
 
var addressCode = '1174010300';
 
var result1 = addressCode.substring(0,2);    
var result2 = addressCode.substring(2,5);
var result3 = addressCode.substring(5,8);
 
 
document.getElementById("result").innerHTML = result1 + '|' + result2 + '|' + result3;
 
 
demo link