std:: strspn
From cppreference.net
C++
Text processing library
| Localization library | |||||||||||||||||||||||||
| Regular expressions library (C++11) | |||||||||||||||||||||||||
| Formatting library (C++20) | |||||||||||||||||||||||||
| Null-terminated sequence utilities | |||||||||||||||||||||||||
| Byte strings | |||||||||||||||||||||||||
| Multibyte strings | |||||||||||||||||||||||||
| Wide strings | |||||||||||||||||||||||||
| Primitive numeric conversions | |||||||||||||||||||||||||
|
|||||||||||||||||||||||||
| Text encoding identifications | |||||||||||||||||||||||||
|
|||||||||||||||||||||||||
Null-terminated byte strings
| Functions | ||||||||||||||||||||||||||||||||||||
| Character classification | ||||||||||||||||||||||||||||||||||||
| Character manipulation | ||||||||||||||||||||||||||||||||||||
| Conversions to numeric formats | ||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||
| String manipulation | ||||||||||||||||||||||||||||||||||||
| String examination | ||||||||||||||||||||||||||||||||||||
| Character array functions | ||||||||||||||||||||||||||||||||||||
| Miscellaneous | ||||||||||||||||||||||||||||||||||||
|
ヘッダーで定義
<cstring>
|
||
|
size_t strspn
(
const
char
*
dest,
const
char
*
src
)
;
|
||
dest が指すバイト文字列の最大初期セグメント(スパン)の長さを返します。このセグメントは、 src が指すバイト文字列に含まれる文字のみで構成されます。
目次 |
パラメータ
| dest | - | 解析対象のヌル終端バイト文字列へのポインタ |
| src | - | 検索対象の文字を含むヌル終端バイト文字列へのポインタ |
戻り値
src が指すバイト文字列からのみの文字を含む最大初期セグメントの長さ。
例
このコードを実行
#include <cstring> #include <iostream> #include <string> const char* low_alpha = "qwertyuiopasdfghjklzxcvbnm"; int main() { std::string s = "abcde312$#@"; std::size_t spnsz = std::strspn(s.c_str(), low_alpha); std::cout << "After skipping initial lowercase letters from '" << s << "'\nThe remainder is '" << s.substr(spnsz) << "'\n"; }
出力:
After skipping initial lowercase letters from 'abcde312$#@' The remainder is '312$#@'
関連項目
|
別のバイト文字列に含まれない文字のみで構成される最大先頭セグメントの長さを返す
(関数) |
|
|
別のワイド文字列に含まれるワイド文字のみで構成される最大先頭セグメントの長さを返す
(関数) |
|
|
区切り文字セットからの任意の文字が最初に現れる位置を検索する
(関数) |
|
|
Cドキュメント
for
strspn
|
|