I have collection of files, the contents of all those files have the following format
-- File name
--
-- listOne (L1)
-- listTwo (L2)
-- listThree (L3)
-- HeaderLine (HE)
-- listFour (L6)
-- listFive (L2)
-- listSix (L9)
-- listSeven (L0)
-- someline (SL)
-- listeight (LL)
--
--
REMAINING CONTENTS OF THE LINE
-----------------------------------------------------------------------
some more contents
------------------------------------------------------------------------
-- File name
--
-- listOne (L1)
-- listTwo (L2)
-- listThree (L3)
-- HeaderLine (HE)
-- listFour (L6)
-- listFive (L2)
-- listSix (L9)
-- listSeven (L0)
-- someline (SL)
-- listeight (LL)
--
--
REMAINING CONTENTS OF THE LINE
-----------------------------------------------------------------------
some more contents
------------------------------------------------------------------------
To copy to clipboard, switch view to plain text mode
Here i want to store only L1,L2,L3 etc in a list, except HE,SL and remaining lines of files
How can i do that?
Please help me, i went through QREgExp class defination also, and i wrote code but that seems to be very big and inserts some blank strings into stored list
while(!f.atEnd() && (!line.contains("------------------------------------------")))
{
if(!line.contains("-- "))
{
flag=1;
QRegExp rx
("[\(]([a-z]|[0-9]|[_]|[A-Z])+[\)]");
rx.indexIn(line);
QRegExp rx1
("([a-z]|[0-9]|[_]|[A-Z])+");
rx1.indexIn(rx.cap(0));
captured.append(rx1.cap(0));
line=f.readLine();
}
else if(flag==1)
{
flag++;
captured.pop_back();
QRegExp rx
("[\(]([a-z]|[0-9]|[_]|[A-Z])+[\)]");
rx.indexIn(line);
QRegExp rx1
("([a-z]|[0-9]|[_]|[A-Z])+");
rx1.indexIn(rx.cap(0));
captured.append(rx1.cap(0));
line=f.readLine();
}
else if(flag>0)
{ flag++;
QRegExp rx
("[\(]([a-z]|[0-9]|[_]|[A-Z])+[\)]");
rx.indexIn(line);
QRegExp rx1
("([a-z]|[0-9]|[_]|[A-Z])+");
rx1.indexIn(rx.cap(0));
captured.append(rx1.cap(0));
line=f.readLine();
}
}
while(!f.atEnd() && (!line.contains("------------------------------------------")))
{
if(!line.contains("-- "))
{
flag=1;
QRegExp rx("[\(]([a-z]|[0-9]|[_]|[A-Z])+[\)]");
rx.indexIn(line);
QRegExp rx1("([a-z]|[0-9]|[_]|[A-Z])+");
rx1.indexIn(rx.cap(0));
captured.append(rx1.cap(0));
line=f.readLine();
}
else if(flag==1)
{
flag++;
captured.pop_back();
QRegExp rx("[\(]([a-z]|[0-9]|[_]|[A-Z])+[\)]");
rx.indexIn(line);
QRegExp rx1("([a-z]|[0-9]|[_]|[A-Z])+");
rx1.indexIn(rx.cap(0));
captured.append(rx1.cap(0));
line=f.readLine();
}
else if(flag>0)
{ flag++;
QRegExp rx("[\(]([a-z]|[0-9]|[_]|[A-Z])+[\)]");
rx.indexIn(line);
QRegExp rx1("([a-z]|[0-9]|[_]|[A-Z])+");
rx1.indexIn(rx.cap(0));
captured.append(rx1.cap(0));
line=f.readLine();
}
}
To copy to clipboard, switch view to plain text mode
Please help me sort this problem
Bookmarks