This might have appeared before, but I couldn't understand how to extract formatted data. Below is my code to extract all text between string "[87]" and "[90]" in a text file.
Apparently, the position of [87] and [90] is the same as indicated in the output.
void ExtractWebContent::filterContent(){ string str, str1; string positionOfCurrency1 = "[87]"; string positionOfCurrency2 = "[90]"; size_t positionOfText1, positionOfText2; ifstream reading; reading.open("file_Currency.txt"); while (!reading.eof()){ getline (reading, str); positionOfText1 = str.find(positionOfCurrency1); positionOfText2 = str.find(positionOfCurrency2); cout << "positionOfCurrency1 " << positionOfText1 << endl; cout << "positionOfCurrency2 " << positionOfText2 << endl; //str1= str.substr (positionOfText); cout << "String" << str1 << endl; } reading.close(); An Update on the currency file:
[79]More »Brent slips to $102 on worries about euro zone economy
Market Data
* Currencies CAPTION: Currencies
Name Price Change % Chg [80]USD/SGD 1.2606 -0.00 -0.13% USD/SGD [81]USDSGD=X [82]EUR/SGD 1.5242 0.00 +0.11% EUR/SGD [83]EURSGD=X