I'd try to parse such of data by using Linq:
var data = msg.Replace("STRUCTURE ERRMSG", string.Empty)
.Split(new string[]{"{", "}", "\n"}, StringSplitOptions.RemoveEmptyEntries)
.Select(x=>new
{
FieldName = x.Split('=')[0].Trim(),
FieldValue = x.Split('=').Count() == 1 ? string.Empty : x.Split('=')[1].Trim()
})
.ToList();
Above code returns:
FieldName FieldValue
FIELD TYPE E
FIELD ID
FIELD NUMBER 000
FIELD MESSAGE Invalid Referral Link
FIELD LOG_NO FIELD
LOG_MSG_NO 000000
FIELD MESSAGE_V1
FIELD MESSAGE_V2
FIELD MESSAGE_V3
FIELD MESSAGE_V4
FIELD PARAMETER FIELD
ROW 0
FIELD FIELD
FIELD SYSTEM
Note: i'd suggest to write custom class with
Parse
method to be able to deal with data.