【发布时间】:2015-06-01 17:15:54
【问题描述】:
大家好,我正在学习 C++ 有很多我还不知道的东西!我想知道如何添加 URL 和编辑?到目前为止我有这个!
我有 3 行数字和 1 行字母,我想删除最后一行数字和字母行
#include <iostream>
#include <string>
#include "stdio.h"
#include "stdlib.h"
#include <algorithm>
using namespace std;
int main()
{
string str("www.google.com/123456789.123456789123.123456789123456.g.testasdgrrsgd");
string str2("www.google.com");
str.replace(str.find(str2), str2.length(), "www.youtube.com/");
//This code changes from "www.google.com" to "www.youtube.com/"
size_t sp = str.find_first_of('.g', 7);
if (sp != string::npos) {
string base_url(str.begin() + 7, str.begin() + sp);
cout << base_url << endl;
sp = str.find_last_of('.g');
if (sp != string::npos) {
string query(str.begin() + sp + 1, str.end());
}
}
system("pause");
return 0;
}
此代码我设法删除了字母行,但无法删除最后一行编号。
我想成为这个最终结果! www.youtube.com/123456789.123456789123
谢谢:)
【问题讨论】: