Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iterator>
- #include <string>
- #include <regex>
- int main()
- {
- std::string s = "Some `people`, when confronted with a problem, think "
- "\"I know, I'll use regular `expressions`.\" "
- "Now they have two problems.";
- std::regex word_regex("`(\\w+)`");
- auto words_begin =
- std::sregex_iterator(s.begin(), s.end(), word_regex);
- auto words_end = std::sregex_iterator();
- for (std::sregex_iterator i = words_begin; i != words_end; ++i) {
- std::cout << " " <<(*i).str() << '\n';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement