JavaScript 文字列

22個の関数

charAtstr.charAt(index)

指定したインデックスの文字を返します。

charCodeAtstr.charCodeAt(index)

指定したインデックスの文字の UTF-16 コードを返します。

concatstr.concat(...strings)

2つ以上の文字列を結合し、新しい文字列を返します。

endsWithstr.endsWith(searchStr, endPos?)

文字列が指定した文字列で終わるか確認します。

includesstr.includes(searchStr, position?)

文字列が特定の文字列を含むかどうかを確認します。

indexOfstr.indexOf(searchStr, fromIndex?)

文字列内で最初に出現するインデックスを返します。

lastIndexOfstr.lastIndexOf(searchStr, fromIndex?)

文字列内で最後に出現するインデックスを返します。

matchstr.match(regexp)

正規表現に一致した結果を配列で返します。

padEndstr.padEnd(targetLen, padStr?)

末尾に文字を追加して指定した長さにします。

padStartstr.padStart(targetLen, padStr?)

先頭に文字を追加して指定した長さにします。

repeatstr.repeat(count)

文字列を n 回繰り返した新しい文字列を返します。

replacestr.replace(searchFor, replaceWith)

最初に一致した文字列を置換します。

replaceAllstr.replaceAll(searchFor, replaceWith)

一致するすべての文字列を置換します。

slicestr.slice(beginIndex, endIndex?)

文字列の一部を抽出して新しい文字列を返します。

splitstr.split(separator, limit?)

区切り文字で分割して配列を返します。

startsWithstr.startsWith(searchStr, position?)

文字列が指定した文字列で始まるか確認します。

toLowerCasestr.toLowerCase()

文字列を小文字に変換します。

toUpperCasestr.toUpperCase()

文字列を大文字に変換します。

trimstr.trim()

先頭と末尾の空白を削除します。

trimEndstr.trimEnd()

末尾の空白を削除します。

trimStartstr.trimStart()

先頭の空白を削除します。

atstr.at(index)

インデックス(負の数も可)の文字を返します。