C++参考demo-提取子串

来源:互联网 发布:如何修改tomcat端口 编辑:程序博客网 时间:2024/06/01 10:41
// test0811.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include <string>#include <iostream>using namespace std;int _tmain(int argc, _TCHAR* argv[]){    //找到h这个词,打印""之间的内容    string str = "abcdefgh+q\"jkeeeee\"lnm";   cout << "str==" << str<< endl;    string temp;    string aaa;    int i = str.find("h");    cout << "i==" << i <<endl;    aaa = str.substr(i+4,8);    cout << "aaa=" << aaa <<endl;    int i3 = aaa.find("\"");    cout << "jige==" << i3 <<endl;    if (i != str.npos)    {        cout << "yes" << i << endl;        temp = str.substr(i+4, i3);        cout << "hello=-=" << temp << endl;    }    return 0;}
原创粉丝点击