std::strspn
提供: cppreference.com
<tbody>
</tbody>
| ヘッダ <cstring> で定義
|
||
size_t strspn( const char* dest, const char* src ); |
||
src の指すバイト文字列内に含まれる文字のみで構成される、 dest の指すバイト文字列の最も長い先頭部分の長さを返します。
引数
| dest | - | 解析するヌル終端バイト文字列を指すポインタ |
| src | - | 検索する文字を含むヌル終端バイト文字列を指すポインタ |
戻り値
src の指すバイト文字列内の文字のみを含む最も長い先頭部分の長さ。
例
Run this code
#include <cstring>
#include <string>
#include <iostream>
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$#@'
関連項目
| 別のバイト文字列に含まれない文字のみで構成される最も長い先頭部分の長さを返します (関数) | |
| 別のワイド文字列に含まれるワイド文字のみで構成される先頭部分の最大の長さを返します (関数) | |
| 区切り文字集合の任意の文字が文字列中に現れる最初の位置を探します (関数) | |
strspn の C言語リファレンス
| |