「cpp/regex/regex iterator/operator*」の版間の差分
提供: cppreference.com
< cpp | regex | regex iterator
23行: | 23行: | ||
#include <regex> | #include <regex> | ||
− | int main() | + | int main() |
− | + | ||
− | std::regex expression ("[1234]"); | + | std::regex expression("[1234]"); |
− | std::string searchStr("1.1a2b3cjk34") | + | std::string searchStr("1.1a2b3cjk34"); |
− | + | ||
− | + | ||
− | + | ( | |
− | std::cout << it->str(); | + | |
− | + | it != ) { | |
− | } | + | std::cout << it->str(); |
+ | } | ||
} | } | ||
| output= 112334 | | output= 112334 |
2019年8月21日 (水) 08:52時点における最新版
const value_type& operator*() const; |
(1) | (C++11以上) |
const value_type* operator->() const; |
(2) | (C++11以上) |
現在の std::match_results を regex_iterator
から取り出します。
1) 現在の std::match_results を指す参照を返します。
2) 現在の std::match_results を指すポインタを返します。
[編集] 例
Run this code
#include <iostream> #include <string> #include <regex> int main() { std::regex expression("[1234]"); std::string searchStr("1.1a2b3cjk34"); for (std::regex_iterator<std::string::iterator> it{ searchStr.begin(), searchStr.end(), expression }, last{}; it != last; ++it) { std::cout << it->str(); } }
出力:
112334