<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <pre>
    <script type="text/javascript">
        var s = " Abc Def Fed Cba ";
        document.writeln(s.length); // 길이
        document.writeln(s.toUpperCase()); // 대문자
        document.writeln(s.toLowerCase()); // 소문자
        document.writeln(s.bold()); // 볼드
        document.writeln(s.italics()); // 이탤릭
        document.writeln(s.charAt(1)); // 1번째 인덱스 : A, C#의 IndexOf()명령어의 역할이다.
        document.writeln(s.substr(1, 3)); // 1번째부터 3자 : C#의 Substring()과 같다.
        document.writeln(s.lastIndexOf("b")); // 뒤에서 b검색 : 14 : C#의 LastIndexOf()와 같다.
        document.writeln(s.replace("Abc", "에이비씨")); // 치환
        var arr = s.split(' '); // 공백으로 분리해서 배열에 저장
        for (var i = 0; i < arr.length; i++) {
            document.writeln(arr[i]);
        }
       
        //[!] 퀴즈 : 아래 dir변수에서 파일명과 확장자를 추출해서 출력하시오.
        var dir = "C:\\Temp\\RedPlus.gif";

        var fullname = dir.substr(dir.lastIndexOf('\\') + 1);
        var name = fullname.substr(0, fullname.lastIndexOf("."));
        var ext = fullname.substr(fullname.lastIndexOf(".") + 1);
        document.writeln("전체파일명 : " + fullname);
        document.writeln("이름 : " + name);
        document.writeln("확장자 : " + ext);
       
    </script>
    </pre>
   
</head>
<body>

</body>
</html>

Posted by holland14
: