Всем привет.
Есть файл такого вида:
*****Block_Number 1*****
System time is 15h13m0s
System date is 27d11m9y
VOLTAGE fazaA=11V fazaB=20V fazaC=29V POWER=0000.0000W
Water sensors1=0
Water sensors2=0 Water sensors3=0 Water sensors4=0 Water sensors5=0 Water sensors6=0
Water sensors7=0 Water sensors8=0 Water sensors9=0 Water sensors10=0 Water sensors11=0
Pressure sensors1=0.00
Pressure sensors2=0.00 Pressure sensors3=0.00 Pressure sensors4=0.00 Pressure sensors5=0.00
Pressure sensors6=0.00 Pressure sensors7=0.00 Pressure sensors8=0.00 Pressure sensors9=0.00
Pressure sensors10=0.00 Pressure sensors11=0.00 Pressure sensors12=0.00 Pressure sensors13=0.00
Pressure sensors14=0.00 Pressure sensors15=0.00
Temperature sensors1= 0.0
Temperature sensors2= 0.0 Temperature sensors3= 0.0 Temperature sensors4= 0.0
Temperature sensors5= 0.0 Temperature sensors6= 0.0 Temperature sensors7= 0.0
Temperature sensors8= 0.0 Temperature sensors9= 0.0 Temperature sensors10= 0.0
Temperature sensors11= 0.0 Temperature sensors12= 0.0 Temperature sensors13= 0.0
Temperature sensors14= 0.0 Temperature sensors15= 0.0 Temperature sensors16= 0.0
Temperature sensors17= 0.0 Temperature sensors18= 0.0 Temperature sensors19= 0.0
Temperature sensors20= 0.0 Temperature sensors21= 0.0
Block number 2 ERROR_READING
Block number 3 ERROR_READING
Block number 4 ERROR_READING
*****Block_Number 1*****
Нужно его распарсить в таком виде
"fazaA=" "11"
"fazaB=" "20"
"fazaC=" "29"
"POWER=" "0000.0000"
"Water sensors1=" "0"
...
"Water sensors11=" "0"
"Pressure sensors1=" "0.00"
...
"Pressure sensors15=" "0.00"
"Temperature sensors1=" "0.0"
...
"Temperature sensors21=" "0.0"
Не могу написать грамотно регулярку. ПОМОГИТЕ.
C++ (Qt)
QString str("Text from file :)");
QRegExp exp("((Water sensors\\d+\\=\\s*)|(faza\\w*\\=\\s*)|(POWER\\=\\s*))(\\d+\\.*\\d*)");
int pos = 0;
while((pos = exp.indexIn(str, pos)) != -1) {
qDebug()<<exp.cap(1)<<exp.cap(2);
pos += exp.matchedLength();
}
Получается вот такая гадость
"fazaA=" ""
"fazaB=" ""
"fazaC=" ""
"POWER=" ""
"Water sensors1=" "Water sensors1="
"Water sensors2=" "Water sensors2="
"Water sensors3=" "Water sensors3="
"Water sensors4=" "Water sensors4="
"Water sensors5=" "Water sensors5="
"Water sensors6=" "Water sensors6="
"Water sensors7=" "Water sensors7="
"Water sensors8=" "Water sensors8="
"Water sensors9=" "Water sensors9="
"Water sensors10=" "Water sensors10="
"Water sensors11=" "Water sensors11="