От: | st0nx | ||
Дата: | 20.05.11 08:05 | ||
Оценка: |
#include <iostream>
#include <vector>
#include <boost/lexical_cast.hpp>
#include <boost/regex.hpp>
#include <fstream>
using namespace std;
int main()
{
ifstream file("file.txt");
ofstream file1("out.txt");
while(!file.eof())
{
std::string fstring;
boost::regex xRegEx("\/\/\/\< \[(.+?)\] - (.+)");
boost::smatch xResults;
std::getline(file, fstring);
std::string::const_iterator xItStart = fstring.begin();
std::string::const_iterator xItEnd = fstring.end();
while( boost::regex_search(xItStart, xItEnd, xResults, xRegEx) )
{
file1 << boost::lexical_cast<std::string>(xResults[1]) <<" "<<boost::lexical_cast<std::string>(xResults[2]);
xItStart = xResults[1].second;
}
}
file.close();
file1.close();
return 0;
}
необходимо получить в выходном:modbusdecl(ModbusTable, modbusR, StartShortAdress + 0, APP_N); ///< [0x500] — Номер применения
modbusdecl(ModbusTable, modbusR, StartShortAdress + 1, TT1.Value); ///< [0x501] — Температрура на притоке
...
На выходе ничего не находится. Непонимаю почему. Регулярку тестил тут: _ttp://www.pcre.ru/eval/0x500 Номер применения
0x501 Температрура на притоке
...