B
baibaichen
hi , i have a string, looks like
~~ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") =
"FileSystemTest", "FileSystemTest_2003.vcproj",
"{ABC6E827-F34C-4E45-B384-AC33DF83803B}" ~~
what i want get is between 5th and 6th doule quote char, i.e.
FileSystemTest_2003.vcproj
is there any general algorithm to complete this simple task in simple
way.
my implementation is :
static const TCHAR quoteChar = '"';
static const TCHAR equalChar = '=';
size_t firstposEqual = data.find(equalChar);
size_t firstposQuote = data.find(quoteChar,++firstposEqual);
if (firstposQuote == string::npos)
return;
size_t secondQuoteChar = data.find(quoteChar,++firstposQuote);
if (secondQuoteChar == string::npos)
return;
//relative path
firstposQuote = data.find(quoteChar,++secondQuoteChar);
if (firstposQuote == string::npos)
return;
secondQuoteChar = data.find(quoteChar,++firstposQuote);
if (secondQuoteChar == string::npos)
return;
string relativePath =
data.substr(firstposQuote,secondQuoteChar-firstposQuote);
i think it is very awful!!
thanks
~~ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") =
"FileSystemTest", "FileSystemTest_2003.vcproj",
"{ABC6E827-F34C-4E45-B384-AC33DF83803B}" ~~
what i want get is between 5th and 6th doule quote char, i.e.
FileSystemTest_2003.vcproj
is there any general algorithm to complete this simple task in simple
way.
my implementation is :
static const TCHAR quoteChar = '"';
static const TCHAR equalChar = '=';
size_t firstposEqual = data.find(equalChar);
size_t firstposQuote = data.find(quoteChar,++firstposEqual);
if (firstposQuote == string::npos)
return;
size_t secondQuoteChar = data.find(quoteChar,++firstposQuote);
if (secondQuoteChar == string::npos)
return;
//relative path
firstposQuote = data.find(quoteChar,++secondQuoteChar);
if (firstposQuote == string::npos)
return;
secondQuoteChar = data.find(quoteChar,++firstposQuote);
if (secondQuoteChar == string::npos)
return;
string relativePath =
data.substr(firstposQuote,secondQuoteChar-firstposQuote);
i think it is very awful!!
thanks