std::regex_token_iterator
提供: cppreference.com
![]() | このページは、Google 翻訳を使って英語版から機械翻訳されました。 翻訳には誤りや奇妙な言い回しがあるかもしれません。文章の上にポインタをおくと、元の文章が見れます。誤りを修正して翻訳を改善する手助けをしてください。翻訳についての説明は、ここをクリックしてください。 |
template< class BidirIt, | (C++11およびそれ以降) | |
std::regex_token_iterator
基礎となる文字シーケンス内の正規表現のすべての試合の個々のサブマッチにアクセスし、読み取り専用ForwardIterator
です。また、与えられた正規表現(トークナイザとしてなど)によって一致しなかった配列の部分にアクセスするために使用することができ.Original:
std::regex_token_iterator
is a read-only ForwardIterator
that accesses the individual sub-matches of every match of a regular expression within the underlying character sequence. It can also be used to access the parts of the sequence that were not matched by the given regular expression (e.g. as a tokenizer).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を構築し、すべての増分にそれは最後のサブマッチからインクリメントするとき、基礎となるregex_iteratorをインクリメントし、現在match_resultsから要求されたサブマッチ〜ステップ.
Original:
On construction, it constructs an std::regex_iterator and on every increment it steps through the requested sub-matches from the current match_results, incrementing the underlying regex_iterator when incrementing away from the last submatch.
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_token_iterator
エンドオブシーケンスイテレータです。有効なstd::regex_token_iterator
が最後の試合の最後のサブマッチに達した後にインクリメントされると、エンド·オブ·シーケンスイテレータと等しくなる。さらにそれを間接参照またはインクリメントすると、未定義の動作を呼び出す.Original:
The default-constructed
std::regex_token_iterator
is the end-of-sequence iterator. When a valid std::regex_token_iterator
is incremented after reaching the last submatch of the last match, 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_token_iterator(非整合フラグメント)が要求されたサブマッチインデックスのリストに表示されている場合だけ、エンドオブシーケンスイテレータになる前に、-1は、サフィックスイテレータになることがあります。このような反復子は、間接参照した場合、最後にマッチし、シーケンスの最後の間に文字の配列に対応するmatch_resultsを返します。.
Original:
Just before becoming the end-of-sequence iterator, a std::regex_token_iterator may become a suffix iterator, if the index -1 (non-matched fragment) appears in the list of the requested submatch indexes. Such iterator, if dereferenced, returns a match_results corresponding to the sequence of characters between the last match and the end of 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_token_iterator
の一般的な実装は、現在のマッチの現在サブマッチ指さし基礎std::regex_iterator、要求されたサブマッチインデックスの容器(例えばstd::vector<int>)、サブマッチ、std::match_resultsへのポインタのインデックスに等しい内部カウンタを保持し、 std::match_results最後の非マッチした文字シーケンスを(トークナイザモードで使用)を含むオブジェクト.Original:
A typical implementation of
std::regex_token_iterator
holds the underlying std::regex_iterator, a container (e.g. std::vector<int>) of the requested submatch indexes, the internal counter equal to the index of the submatch, a pointer to std::match_results, pointing at the current submatch of the current match, and a std::match_results object containing the last non-matched character sequence (used in tokenizer mode).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.
Defined in header <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_token_iterator | regex_token_iterator<constchar*> |
wcregex_token_iterator | regex_token_iterator<constwchar_t*> |
sregex_token_iterator | regex_token_iterator<std::string::const_iterator> |
wsregex_token_iterator | regex_token_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::sub_match<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_token_iteratorを構築します Original: constructs a new regex_token_iterator The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (パブリックメンバ関数) | |
(destructor) (暗黙的に宣言された) | destructs a regex_token_iterator, including the cached value (パブリックメンバ関数) |
regex_token_iteratorを置き換えます Original: replaces a regex_token_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_token_iteratorsを比較します Original: compares two regex_token_iterators The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (パブリックメンバ関数) | |
現在サブマッチをaccsses Original: accsses current submatch The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (パブリックメンバ関数) | |
次のサブマッチに進みregex_token_iterator Original: advances the regex_token_iterator to the next submatch 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オブジェクトがイテレータを長生きことを保証するためには、プログラマの責任です。反復子は、未定義の動作のregexが破壊された結果の後にイテレータをインクリメントする、正規表現へのポインタを格納しstd::regex_iteratorを格納するため、.
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 std::regex_iterator which stores a pointer to the regex, incrementing the iterator after the regex was destroyed results in 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.
[編集]例
このコードを実行します
#include <fstream>#include <iostream>#include <algorithm>#include <iterator>#include <regex>int main(){std::string text ="Quick brown fox.";// tokenization (non-matched fragments)// Note that regex is matched only two times: when the third value is obtained// the iterator is a suffix iterator.std::regex ws_re("\\s+");// whitespacestd::copy( std::sregex_token_iterator(text.begin(), text.end(), ws_re, -1), std::sregex_token_iterator(), std::ostream_iterator<std::string>(std::cout, "\n")); // iterating the first submatchesstd::string html ="<p><a href=\"http://google.com\">google</a> ""< a HREF =\"http://cppreference.com\">cppreference</a>\n</p>";std::regex url_re("<\\s*A\\s+[^>]*href\\s*=\\s*\"([^\"]*)\"", std::regex::icase);std::copy( std::sregex_token_iterator(html.begin(), html.end(), url_re, 1), std::sregex_token_iterator(), std::ostream_iterator<std::string>(std::cout, "\n"));}
出力:
Quick brown fox. http://google.com http://cppreference.com