Boost之正则表达式Regex库的使用方法

这个程序可以简洁的挑出了目标字符串。

#include    
#include    
#include    
#include 
#include    
#include    
using namespace std;  
using namespace boost;  

regex expression("^select ([a-zA-Z]*) from ([a-zA-Z]*)");//定义正则表达式expression   

int main(int argc, char* argv[])  
{  
    std::string in;  
    cmatch what;  
    cout << "enter test string" << endl;  
    getline(cin,in);  
    if(regex_match(in.c_str(), what, expression))//regex_match:匹配算法,用于测试一个字符串是否和正则式匹配   
    {  
        for(int i=0;i

你可能感兴趣的:(Boost之正则表达式Regex库的使用方法)