"String length"의 두 판 사이의 차이

 
(사용자 3명의 중간 판 7개는 보이지 않습니다)
12번째 줄: 12번째 줄:
==Bash==
==Bash==
[[category:Bash]]
[[category:Bash]]
<source lang='bash'>
<syntaxhighlight lang='bash'>
LENGTH=`expr length "hello"`
expr length "hello"
echo $LENGTH
# 5
# 5
</source>
</syntaxhighlight>
 
==C++==
{{참고|C++ .length()}}
<syntaxhighlight lang='cpp'>
#include <iostream>
using namespace std;
int main() {
string str = "abcdef";
cout << str.length() << endl;
// 6
}
</syntaxhighlight>


==C#==
==C#==
[[category: Csharp]]
[[category: Csharp]]
<source lang="csharp">
<syntaxhighlight lang="csharp">
"hello".Length;      // returns 5
"hello".Length;      // returns 5
"".Length;          // returns 0
"".Length;          // returns 0
</source>
</syntaxhighlight>


==Erlang==
==Erlang==
[[category: Erlang]]
[[category: Erlang]]
<source lang="text">
<syntaxhighlight lang="text">
string:len("hello"). %  returns 5
string:len("hello"). %  returns 5
string:len("").      %  returns 0
string:len("").      %  returns 0
</source>
</syntaxhighlight>


==Java==
==Java==
[[category: Java]]
[[category: Java]]
<source lang="java">
<syntaxhighlight lang="java">
"hello".length()  // returns 5
"hello".length()  // returns 5
"".length()        // returns 0
"".length()        // returns 0
</source>
</syntaxhighlight>


==JavaScript==
==JavaScript==
[[category: JavaScript]]
[[category: JavaScript]]
<source lang='javascript'>
<syntaxhighlight lang='javascript'>
var txt = "Hello World!";
var txt = "Hello World!";
var len = txt.length; // 12
var len = txt.length; // 12
</source>
</syntaxhighlight>


==Lua==
==Lua==
[[category: Lua]]
[[category: Lua]]
<source lang="lua">
<syntaxhighlight lang="lua">
("hello"):len() -- returns 5
("hello"):len() -- returns 5
#"" -- returns 0
#"" -- returns 0
</source>
</syntaxhighlight>


==Objective-C==
==Objective-C==
[[category: Objective-C]]
[[category: Objective-C]]
<source lang="objc">
<syntaxhighlight lang="objc">
[@"hello" length]  // returns 5
[@"hello" length]  // returns 5
[@"" length]        // returns 0
[@"" length]        // returns 0
</source>
</syntaxhighlight>


==Perl==
==Perl==
[[category: Perl]]
[[category: Perl]]
<source lang="perl">
<syntaxhighlight lang="perl">
length("hello");    #  returns 5
length("hello");    #  returns 5
length("");          #  returns 0
length("");          #  returns 0
</source>
</syntaxhighlight>


==PHP==
==PHP==
[[category: PHP]]
[[category: PHP]]
<source lang="php">
<syntaxhighlight lang="php">
strlen('hello');    //  returns 5
strlen('hello');    //  returns 5
strlen('');          //  returns 0
strlen('');          //  returns 0
</source>
</syntaxhighlight>


==Python==
==Python==
[[category: Python]]
[[category: Python]]
<source lang="python">
<syntaxhighlight lang="python">
len('hello')    #  returns 5
len('hello')    #  returns 5
len('')          #  returns 0
len('')          #  returns 0
</source>
</syntaxhighlight>


==Ruby==
==Ruby==
[[category: Ruby]]
[[category: Ruby]]
<source lang="ruby">
<syntaxhighlight lang="ruby">
'hello'.length     # returns 5
print 'hello'.length
''.length         # returns 0
# 5
</source>
print ''.length
# 0
</syntaxhighlight>


==SQL==
==SQL==
92번째 줄: 105번째 줄:
===MySQL===
===MySQL===
[[category: MySQL]]
[[category: MySQL]]
<source lang='sql'>
<syntaxhighlight lang='sql'>
SELECT LENGTH( "hello" )
SELECT LENGTH( "hello" )
-- 5
-- 5
</source>
</syntaxhighlight>


==VB==
==VB==
[[category: VB]]
[[category: VB]]
<source lang="vb">
<syntaxhighlight lang="vb">
Len("hello")        '  returns 5
Len("hello")        '  returns 5
Len("")              '  returns 0
Len("")              '  returns 0
</source>
</syntaxhighlight>


==See also==
==같이 보기==
*[[utf8_strlen]]
*[[utf8_strlen]]
*[[count]]
*[[count]]
*[[substring]]
*[[substring]]
*[[stringReverse()]]
*[[new string]]
*[[문자열]]
*[[길이]]


==References==
==References==
* http://eqcode.com/wiki/string_length
* http://eqcode.com/wiki/string_length

2024년 1월 8일 (월) 00:16 기준 최신판


1 Overview[ | ]

len
length
strlen
  • Definition: length(string) returns an integer number
  • Description: Returns the length of a string (not counting the null terminator or any other of the string's internal structural information). An empty string returns a length of 0.

2 Bash[ | ]

expr length "hello"
# 5

3 C++[ | ]

#include <iostream>
using namespace std;
int main() {
	string str = "abcdef";
	cout << str.length() << endl;
	// 6
}

4 C#[ | ]

"hello".Length;      // returns 5
"".Length;           // returns 0

5 Erlang[ | ]

string:len("hello"). %  returns 5
string:len("").      %  returns 0

6 Java[ | ]

"hello".length()   // returns 5
"".length()        // returns 0

7 JavaScript[ | ]

var txt = "Hello World!";
var len = txt.length; // 12

8 Lua[ | ]

("hello"):len() -- returns 5
#"" -- returns 0

9 Objective-C[ | ]

[@"hello" length]   // returns 5
[@"" length]        // returns 0

10 Perl[ | ]

length("hello");     #  returns 5
length("");          #  returns 0

11 PHP[ | ]

strlen('hello');     //  returns 5
strlen('');          //  returns 0

12 Python[ | ]

len('hello')     #  returns 5
len('')          #  returns 0

13 Ruby[ | ]

print 'hello'.length
# 5
print ''.length
# 0

14 SQL[ | ]

14.1 MySQL[ | ]

SELECT LENGTH( "hello" )
-- 5

15 VB[ | ]

Len("hello")         '  returns 5
Len("")              '  returns 0

16 같이 보기[ | ]

17 References[ | ]