文字列

文字列表現

Jasmine Tea

"Taro Yamada"
"1+2の答えは、"
"This is a pen. That's a pencil."
"1234567890"

JavaScript

"Taro Yamada"
'1+2の答えは、'
"This is a pen. That's a pencil."
'1234567890'

Python

"Taro Yamada"
'1+2の答えは、'
"This is a pen. That's a pencil."
'1234567890'

文字列の連結

Jasmine Tea

"Hello" + ", " + "world!"  // "Hello, world!"

JavaScript

"Hello" + ", " + "world!"  // "Hello, world!"

Python

"Hello" + ", " + "world!"  // "Hello, world!"

文字列の長さの取得

Jasmine Tea

len("Hello, world!")  // 13

JavaScript

"Hello, world!".length  // 13

Python

len("Hello, world!")  // 13

ある文字が含まれているかを知りたい

Jasmine Tea

include("Hello", "ll")  // -1
include("Hello", "w")   // 0

JavaScript

"Hello".includes("ll")  // true
"Hello".includes("w")   // false

Python

"ll" in "Hello"  // True
"w" in "Hello"   // False

部分文字列の取得

Jasmine Tea

left$("Hello, world!", 5)   // "Hello"
right$("Hello, world!", 6)  // "world!"
mid$("Hello, world!", 7,5)  // "world"

JavaScript

"Hello, world!".substring(0, 5)   // "Hello"
"Hello, world!".slice(-6)         // "world!"
"Hello, world!".substring(7, 12)  // "world"

Python

"Hello, world!"[0:5]   // "Hello"
"Hello, world!"[-6:]   // "world!"
"Hello, world!"[7:12]  // "world"

文字コードの取得

Jasmine Tea

asc("a")  // 97

JavaScript

"a".charCodeAt(0)  // 97

Python

ord("a")  // 97

文字コードから文字を取得

Jasmine Tea

chr$(97)  // "a"

JavaScript

String.fromCharCode(97)  // "a"

Python

chr(97)  // "a"

数値を文字に変換

Jasmine Tea

str$(123.45)  // "123.45"

JavaScript

String(123.45)  // "123.45"

Python

str(123.45)  // "123.45"