std::regex_iterator
提供: cppreference.com
![]() | このページは、Google 翻訳を使って英語版から機械翻訳されました。 翻訳には誤りや奇妙な言い回しがあるかもしれません。文章の上にポインタをおくと、元の文章が見れます。誤りを修正して翻訳を改善する手助けをしてください。翻訳についての説明は、ここをクリックしてください。 |
template< class BidirIt, | (C++11およびそれ以降) | |
std::regex_iterator
基礎となる文字シーケンス内の正規表現の個人戦にアクセスする読み取り専用ForwardIterator
です.Original:
std::regex_iterator
is a read-only ForwardIterator
that accesses the individual matches of a regular expression within the underlying character sequence.The text has been machine-translated via Google Translate.
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.
建設上の、すべての増分で、それはstd::regex_search呼び出し、結果を(つまり、値std::match_results<BidirIt>のコピーを保存します)覚えています。イテレータが構築されるか、最初の逆参照が行われたときの最初のオブジェクトを読み取ることができます。それ以外の場合、間接参照すると、最も最近得られた正規表現マッチのコピーを返します。.
Original:
On construction, and on every increment, it calls std::regex_search and remembers the result (that is, saves a copy of the value std::match_results<BidirIt>). The first object may be read when the iterator is constructed or when the first dereferencing is done. Otherwise, dereferencing only returns a copy of the most recently obtained regex match.
The text has been machine-translated via Google Translate.
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.
デフォルト構築
std::regex_iterator
エンドオブシーケンスイテレータです。有効なstd::regex_iterator
が最後に試合を(std::regex_search戻りfalse)に達した後にインクリメントされると、エンド·オブ·シーケンスイテレータと等しくなる。さらにそれを間接参照またはインクリメントすると、未定義の動作を呼び出す.Original:
The default-constructed
std::regex_iterator
is the end-of-sequence iterator. When a valid std::regex_iterator
is incremented after reaching the last match (std::regex_search returns false), it becomes equal to the end-of-sequence iterator. Dereferencing or incrementing it further invokes undefined behavior.The text has been machine-translated via Google Translate.
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.
std::regex_iterator
の典型的な実装が始まり、基礎となるシーケンス(BidirItの2つのインスタンス)、正規表現(const regex_type*)とマッチフラグ(std::regex_constants::match_flag_type)へのポインタ、および現在のマッチ(std::match_results<BidirIt>)の終了イテレータを保持している.Original:
A typical implementation of
std::regex_iterator
holds the begin and the end iterators for the underlying sequence (two instances of BidirIt), a pointer to the regular expression (const regex_type*) and the match flags (std::regex_constants::match_flag_type), and the current match (std::match_results<BidirIt>).The text has been machine-translated via Google Translate.
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.
目次 |
[編集]型の要件
-BidirIt は BidirectionalIterator の要件を満たさなければなりません。 |
[編集]スペシャ
一般的な文字のシーケンス型にはいくつかの特殊化が定義されています
Original:
Several specializations for common character sequence types are defined:
The text has been machine-translated via Google Translate.
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.
ヘッダ <regex> で定義 | |
タイプ Original: Type The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | Definition |
cregex_iterator | regex_iterator<constchar*> |
wcregex_iterator | regex_iterator<constwchar_t*> |
sregex_iterator | regex_iterator<std::string::const_iterator> |
wsregex_iterator | regex_iterator<std::wstring::const_iterator> |
[編集]メンバータイプ
メンバー·タイプ Original: Member type The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | Definition |
value_type | std::match_results<BidirIt> |
difference_type | std::ptrdiff_t |
pointer | const value_type* |
reference | const value_type& |
iterator_category | std::forward_iterator_tag |
regex_type | basic_regex<CharT, Traits> |
[編集]メンバ関数
が新しいregex_iteratorを構築します Original: constructs a new regex_iterator The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (パブリックメンバ関数) | |
デストラクタ (暗黙的に宣言) | destructs a regex_iterator, including the cached value (パブリックメンバ関数) |
として知られている、より精巧なソリューションを提供します。 regex_iteratorを置き換えます Original: replaces a regex_iterator The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (パブリックメンバ関数) | |
2 regex_iteratorsを比較します Original: compares two regex_iterators The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (パブリックメンバ関数) | |
現在への言及は、現在のマッチのメンバーをmatch accesses取得します Original: obtains a reference to the current match accesses a member of the current match The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (パブリックメンバ関数) | |
次の試合に進みregex_iterator Original: advances the regex_iterator to the next match The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (パブリックメンバ関数) |
[編集]ノート
これは、イテレータのコンストラクタに渡されたstd::basic_regexオブジェクトがイテレータを長生きことを保証するためには、プログラマの責任です。反復子は、正規表現が破壊された後にイテレータをインクリメントする、正規表現へのポインタを格納するため、ダングリングポインタにアクセスし.
Original:
It is the programmer's responsibility to ensure that the std::basic_regex object passed to the iterator's constructor outlives the iterator. Because the iterator stores a pointer to the regex, incrementing the iterator after the regex was destroyed accesses a dangling pointer.
The text has been machine-translated via Google Translate.
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.
マッチした正規表現の一部がちょうどアサーション(
^
、$
、\b
、\B
)の場合、反復子に格納されている試合は長さゼロのマッチ、match[0].first== match[0].secondです.Original:
If the part of the regular expression that matched is just an assertion (
^
, $
, \b
, \B
), the match stored in the iterator is a zero-length match, that is, match[0].first== match[0].second.The text has been machine-translated via Google Translate.
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.
[編集]例
Run this code
#include <regex>#include <iterator>#include <iostream> int main(){conststd::string text ="Quick brown fox."; std::regex re("[^\\s]+");auto beg = std::sregex_iterator(text.begin(), text.end(), re);auto end = std::sregex_iterator(); std::cout<<"The number of words is "<<std::distance(beg, end)<<'\n';}
出力:
The number of words is 3
[編集]参照
(C++11) | すべての部分表現のマッチを含む1つの正規表現マッチを識別します (クラステンプレート) |
(C++11) | 正規表現は、文字列内の任意の場所に発生するかどうかを確認します Original: check if a regular expression occurs anywhere within a string The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) |