JQuery 문자열 캡 처 사용 요약

25825 단어 전단
1.접미사 붙 이기
var fileDir = "helloworld.exe";
var suffix = fileDir.substr(fileDir.lastIndexOf("."));
//suffix   .exe

2.join()함수
//                     ;
var list=new Array(”h”,”e”,”l”,”l”,”o”); 
var newList=list.join(-); 
//   h-e-l-l-o

3.substring()과 substr()방법
//substring                        
//substr                          
var str = "0123456789"; 
alert(str.substring(0));------------"0123456789" 
alert(str.substring(5));------------"56789" 
alert(str.substring(10));-----------"" 
alert(str.substring(-5));-----------"0123456789" 
alert(str.substring(-12));----------"0123456789" 
alert(str.substring(0,5));----------"01234" 
alert(str.substring(0,10));---------"0123456789" 
alert(str.substring(2,0));----------"01" 
alert(str.substring(2,2));----------"" 
alert(str.substring(2,5));----------"234" 
alert(str.substring(2,-2));---------"01" 
alert(str.substring(-1,5));---------"01234" 
alert(str.substring(-1,-5));--------"" 
 
alert(str.substr(0));---------------"0123456789" 
alert(str.substr(5));---------------"56789" 
alert(str.substr(10));--------------"" 
alert(str.substr(-5));--------------"0123456789" 
alert(str.substr(-10));-------------"0123456789" 
alert(str.substr(-12));-------------"0123456789" 
alert(str.substr(0,5));-------------"01234" 
alert(str.substr(0,10));------------"0123456789" 
alert(str.substr(2,0));-------------"" 
alert(str.substr(2,2));-------------"23" 
alert(str.substr(2,5));-------------"23456" 
alert(str.substr(2,-2));------------"" 
alert(str.substr(-1,5));------------"01234" 
alert(str.substr(-1,-5));-----------"" 

4.indexOf()함수
//                    
var test = ”javaScript”; 
var a=test.indexOf(”v”); // x = 2;
var b=test.indexOf(S); // y = 4; 
var c=test.indexOf(”Script”); // z = 4; 
var d=test.indexOf(”key”); // a = -1;

5.split()방법
<script type="text/javascript">
    var str="What are you saying?"  
    document.write(str.split(" ") + "
"
) document.write(str.split("") + "
"
) document.write(str.split(" ",3)) </script> : What,are,you,saying? W,h,a,t, ,a,r,e, ,y,o,u, ,s,a,y,i,n,g,? What,are,you

좋은 웹페이지 즐겨찾기