C++字符串查找和替换

#include 
#include 
using namespace std;

void string_replace(string &str, const string old0, const string new0);
int main(int argc, char* argv[])
{
	string str = "--++---Hello World---++--";
	string strKey = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghikjlmnopqrstuvwxyz";
	string::size_type nPos0 = str.find_first_of(strKey);
	if(nPos0 == string::npos) return -1;

	string::size_type nPos1 = str.find_last_of(strKey);
	if(nPos1 == string::npos) return -1;
	
	string newstr = str.substr(nPos0, nPos1 - nPos0 + 1);
	cout <<"ner string: " <

你可能感兴趣的:(c++/c)