文字列の長さの取得

Contents

出力結果

5

プログラム例

JavaScript

let str = "A-B-C";
console.log(str.length);

Perl

my $str = "A-B-C";
print length($str)."\n";

PHP

<?php
$str = "A-B-C";
print strlen($str)."\n";

Python

example = "A-B-C"
print(str(len(example)))

Ruby

str = "A-B-C";
print(str.length.to_s + "\n")