using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"^(?=.*\bDATA1=""(?<d1>[^""]+)""\h*)?(?=.*\bDATA2=""(?<d2>[^""]+)""\h*)?(?=.*\bDATA3=""(?<d3>[^""]+)""\h*)?(?=.*\bDATA4=""(?<d4>[^""]+)""\h*)?(?=.*\bDATA5=""(?<d5>[^""]+)""\h*)?.*";
string substitution = @"${d1}\t\t${d2}\t\t${d3}\t\t${d4}\t\t${d5}";
string input = @"DATA1=""8DE"" DATA2=""322"" DATA3=""20"" DATA4=""19.99"" DATA5=""0.01""
DATA1=""FE4"" DATA2=""222"" DATA4=""400"" DATA3=""400"" DATA5=""0.00""
DATA1=""CE3"" DATA2=""444"" DATA4=""60"" DATA5=""0.00"" DATA3=""60""
DATA1=""MME"" DATA3=""20"" DATA4=""20"" DATA5=""0.00""
DATA2=""667"" DATA4=""30"" DATA3=""30"" DATA5=""0.00"" DATA1=""MH4""";
RegexOptions options = RegexOptions.Multiline;
Regex regex = new Regex(pattern, options);
string result = regex.Replace(input, substitution);
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx