std::basic_string::replace
![]() | このページは、Google 翻訳を使って英語版から機械翻訳されました。 翻訳には誤りや奇妙な言い回しがあるかもしれません。文章の上にポインタをおくと、元の文章が見れます。誤りを修正して翻訳を改善する手助けをしてください。翻訳についての説明は、ここをクリックしてください。 |
basic_string& replace( size_type pos, size_type count, const basic_string& str ); | (1) | |
basic_string& replace( size_type pos, size_type count, const basic_string& str, | (2) | |
basic_string& replace( size_type pos, size_type count, const CharT* cstr, size_type count2 ); | (3) | |
basic_string& replace( size_type pos, size_type count, const CharT* cstr ); | (4) | |
basic_string& replace( size_type pos, size_type count, size_type count2, CharT ch ); | (5) | |
basic_string& replace( const_iterator first, const_iterator last, std::initializer_list<CharT> ilist ); | (6) | (C++11およびそれ以降) |
[pos, pos + count)
または[first, last)
いずれかで示される文字列の一部を置き換え.[pos, pos + count)
or [first, last)
with a new string.You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
str
str
You can help to correct and verify the translation. Click here for instructions.
[pos2, pos2 + count2)
でstr
または部分文字列[first2, last2)
[pos2, pos2 + count2)
of str
or characters in the range [first2, last2)
You can help to correct and verify the translation. Click here for instructions.
count2
のcharctersはcstr
が指すcount2
charcters of the character string pointed to by cstr
You can help to correct and verify the translation. Click here for instructions.
cstr
が指すcstr
You can help to correct and verify the translation. Click here for instructions.
count2
のch
コピーcount2
copies of character ch
You can help to correct and verify the translation. Click here for instructions.
ilist
の文字ilist
You can help to correct and verify the translation. Click here for instructions.
目次 |
[編集]パラメータ
pos | - | 置換される文字列の開始 Original: start of the substring that is going to be replaced The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
count | - | 置換される文字列の長さ Original: length of the substring that is going to be replaced The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
first, last | - | 置換される文字の範囲を指定します Original: range of characters that is going to be replaced The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
str | - | 交換のために使用する文字列 Original: string to use for replacement The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
pos2 | - | と交換する部分文字列の開始 Original: start of the substring to replace with The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
count2 | - | と置換する文字の数 Original: number of characters to replace with The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
cstr | - | 交換のために使用する文字列へのポインタ Original: pointer to the character string to use for replacement The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
ch | - | 交換のために使用する文字列値 Original: character value to use for replacement The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
first2, last2 | - | 交換のために使用する文字の範囲を指定します Original: range of characters to use for replacement The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
init | - | 交換のために使用する文字を使用した初期化子リスト Original: initializer list with the characters to use for replacement The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
型の要件 | ||
-InputIt は InputIterator の要求を満足しなければなりません。 |
[編集]値を返します
*this
[編集]例外
std::out_of_range if pos > length()
or pos2 > str.length()
std::string::npos - 1
)超えた場合std::string::npos - 1
)You can help to correct and verify the translation. Click here for instructions.
[編集]例
#include <iostream>#include <string> int main(){std::string str("The quick brown fox jumps over the lazy dog."); str.replace(10, 5, "red");// (4) str.replace(str.begin(), str.begin()+3, 1, 'A');// (5) std::cout<< str <<'\n';}
出力:
A quick red fox jumps over the lazy dog.