PDA

View Full Version : QRegExp having trouble getting the mail position key ....



patrik08
8th October 2013, 07:41
Hi all together,

I like to get a special mail key
its name is:

boundary='------------000501030500080101060708'
boundary="------------000501030500080101060708"
boundary=------------000501030500080101060708
boundary=------------000501030500080101060708;

before line its name Content-Type: multipart/mixed; or nothing
Mail format having rfc2822 ... and real mail having special formats...

after this boundary key its space new line or tabs or other setting

this function here get the key but on result i found
'------------000501030500080101060708'
or
"------------000501030500080101060708"
or
------------000501030500080101060708;

How i can better handle?





/// Get a list of all boundary= key from mail
/// not parse after Meta header --- if mail attachment having
/// a ***.eml message/rfc822 file format. plain tex take ..
/// maximum boundary= is 2x on multipart/mixed && multipart/alternative
//// if search on full body or only header having diff ....problem deep
/// capture boundary='------------000501030500080101060708' ok
/// capture boundary="------------000501030500080101060708" ok
/// capture boundary=------------000501030500080101060708 oK


QStringList Parser::GetMailKey(bool full) const {
QStringList keylist;
/// QRegExp expression("boundary=(.*)[\"\'\\s\\n\\r]", Qt::CaseInsensitive);
QRegExp expression("boundary[\\S'](.*)[\\s]", Qt::CaseInsensitive);
expression.setMinimal(true);
int iPosition = 0;
//// search only on Mail Header part...
/// the second boundary can stay at bottom of mail crazy!!!!
if (full) {
///// find boundary= on complete mail chunk
while ((iPosition = expression.indexIn(Mfull_A, iPosition)) != -1) {
//// _stripcore remove ' " : ; at end or begin key
QString marker = _stripcore(expression.cap(1));
keylist.append(marker);
iPosition += expression.matchedLength();
}
return keylist;
} else {
///// find boundary= on mail header l chunk to parse down in the deep see from no standard mail
while ((iPosition = expression.indexIn(Mheader, iPosition)) != -1) {
QString marker = _stripcore(expression.cap(1));
keylist.append(marker);
iPosition += expression.matchedLength();
}
return keylist;
}

}

}