"함수 ucfirst()"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-source +syntaxhighlight))
 
(다른 사용자 한 명의 중간 판 10개는 보이지 않습니다)
4번째 줄: 4번째 줄:
* "uppercase first"
* "uppercase first"
* 첫글자를 대문자로 바꾸는 함수
* 첫글자를 대문자로 바꾸는 함수
==Java==
[[분류: Java]]
{{참고|자바 ucfirst()}}
<syntaxhighlight lang='Java'>
public class MyClass {
    static String ucfirst(String str) {
        return  str.substring(0, 1).toUpperCase() + str.substring(1);
    }
    public static void main(String args[]) {
        System.out.println( ucfirst("hello world!") ); // Hello world!
        System.out.println( ucfirst("HELLO WORLD!") ); // HELLO WORLD!
    }
}
</syntaxhighlight>
==JavaScript==
{{참고|자바스크립트 ucfirst()}}
<syntaxhighlight lang='javascript'>
function ucfirst(s) { return s.charAt(0).toUpperCase()+s.slice(1); }
console.log( ucfirst('hello world!') );
// Hello world!
console.log( ucfirst('HELLO WORLD!') );
// HELLO WORLD!
</syntaxhighlight>
==Perl==
[[category: Perl]]
{{참고|펄 ucfirst()}}
<syntaxhighlight lang='perl'>
print ucfirst('hello world!');
# Hello world!
</syntaxhighlight>
<syntaxhighlight lang='perl'>
print ucfirst('HELLO WORLD!');
# HELLO WORLD!
</syntaxhighlight>
==PHP==
[[분류: PHP]]
{{참고|PHP ucfirst()}}
<syntaxhighlight lang='php'>
echo ucfirst( 'hello world!' );
# Hello world!
</syntaxhighlight>
<syntaxhighlight lang='php'>
echo ucfirst( 'HELLO WORLD!' );
# HELLO WORLD!
</syntaxhighlight>


==Python==
==Python==
[[분류: Python]]
[[분류: Python]]
{{참고|파이썬 ucfirst()}}
{{참고|파이썬 ucfirst()}}
<source lang='python'>
<syntaxhighlight lang='python'>
s = 'hello world!'
s = 'hello world!'
print ( s[0].upper() + s[1:] )
print ( s[0].upper() + s[1:] )
15번째 줄: 64번째 줄:
print ( s[0].upper() + s[1:] )
print ( s[0].upper() + s[1:] )
# HELLO WORLD!
# HELLO WORLD!
</source>
</syntaxhighlight>


==같이 보기==
==같이 보기==
* [[함수 capitalize()]]
* [[함수 capitalize()]]
* [[함수 ucwords()]]

2020년 11월 2일 (월) 02:33 기준 최신판

1 개요[ | ]

함수 ucfirst()
  • "uppercase first"
  • 첫글자를 대문자로 바꾸는 함수

2 Java[ | ]

public class MyClass {
    static String ucfirst(String str) {
        return  str.substring(0, 1).toUpperCase() + str.substring(1);
    }
    public static void main(String args[]) {
        System.out.println( ucfirst("hello world!") ); // Hello world!
        System.out.println( ucfirst("HELLO WORLD!") ); // HELLO WORLD!
    }
}

3 JavaScript[ | ]

function ucfirst(s) { return s.charAt(0).toUpperCase()+s.slice(1); }
console.log( ucfirst('hello world!') );
// Hello world!
console.log( ucfirst('HELLO WORLD!') );
// HELLO WORLD!

4 Perl[ | ]

print ucfirst('hello world!');
# Hello world!
print ucfirst('HELLO WORLD!');
# HELLO WORLD!

5 PHP[ | ]

echo ucfirst( 'hello world!' );
# Hello world!
echo ucfirst( 'HELLO WORLD!' );
# HELLO WORLD!

6 Python[ | ]

s = 'hello world!'
print ( s[0].upper() + s[1:] )
# Hello world!
s = 'HELLO WORLD!'
print ( s[0].upper() + s[1:] )
# HELLO WORLD!

7 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}