Created
May 3, 2014 15:55
-
-
Save hyqhyq3/7ea24148d9792ff69664 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <boost/regex.hpp> | |
#include <iostream> | |
int main() | |
{ | |
boost::regex e("(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])"); | |
boost::match_results<std::string::const_iterator> what; | |
const std::string str("哈哈哈 8.8.8.8 1.2.3.4 256.256.247.1"); | |
auto first = str.begin(); | |
auto last = str.end(); | |
std::cout << "string is " << str << std::endl; | |
while(boost::regex_search(first, last, what, e)) | |
{ | |
std::cout << std::string(what[0].first, what[0].second) << std::endl; | |
first = what[0].second; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment