String.indexOf()
名称
String.indexOf()
説明
Stringオブジェクト内の文字列の、指定した文字もしくは他のStringオブジェクト内の文字列が存在する位置を返す。デフォルトでは、Stringオブジェクト内の文字列の先頭から最後に向かって調べる。しかし、開始位置を与えることもできる。これにより、Stringオブジェクト内の全ての文字や他のStringオブジェクト内の文字列を調べることができる。
書式
int indexOf( char ch ) const;
int indexOf( char ch, unsigned int fromIndex ) const;
int indexOf( const String &str ) const;
int indexOf( const String &str, unsigned int fromIndex ) const;
引数
| ch, str |
|
| fromIndex |
|
戻り値
指定した文字やStringオブジェクト内の文字列が見つかったときは、検索対象のStringオブジェクト内の文字列の開始位置(0から始まる)、見つからなかった場合は-1を返す。
参照
オリジナルのページ
https://docs.arduino.cc/language-reference/en/variables/data-types/stringObject/Functions/indexOf/
最終更新日
July 22, 2026