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

(새 문서: category:string category:int ==Overview== *len *length *strlen *Definition: length(string) returns an integer number *Description: Returns the length of a string (not count...)
 
39번째 줄: 39번째 줄:
</source>
</source>


==Javascript==
==JavaScript==
[[category: Javascript]]
[[category: JavaScript]]
<source lang='javascript'>
<source lang='javascript'>
var txt = "Hello World!";
var txt = "Hello World!";

2013년 12월 15일 (일) 21:17 판


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

LENGTH=`expr length "hello"`
echo $LENGTH
# 5

3 C#

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

4 Erlang

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

5 Java

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

6 JavaScript

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

7 Lua

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

8 Objective-C

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

9 Perl

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

10 PHP

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

11 Python

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

12 Ruby

'hello'.length     #  returns 5
''.length          #  returns 0

13 SQL

13.1 MySQL

SELECT LENGTH( "hello" )
-- 5

14 VB

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

15 See also

16 References