using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"((^0)\s+|(^1)\s+|(^2)\s+|(^3)\s+|(^4)\s+|(^5)\s+)((((.{4})(.+)))|((.{4})))";
string substitution = @"\n $1 | $2 | $3 | $4 | $5 | $6 | $7 | $8 | $9 | $10 | $11 | $12 | $13 | $14 | |";
string input = @"0 @I0066@ INDI
1 NAME Joan Adrienne /Hatch/
2 GIVN Joan Adrienne
2 SURN Hatch
2 SOUR @S0045@
3 DATA
4 TEXT Birth date: 30 May 1935 Birth place: Hennepin, Minnesota
2 SOUR @S0131@
3 PAGE Source Citation: Year: 1940; Census Place: Faribault, Rice, Minnesota; Roll: T627_1953; Page: 8B; Enumeration District: 66-9A
3 DATA
4 TEXT residence date: 1 Apr 1940 residence place: Faribault, Rice, Minnesot
5 CONC a, United States birth date: May 30, 1935 birth place: Minneapolis
5 CONC , Hennepin, Minnesota, USA Name: Joan Adrienne Hatch
3 NOTE @N0121@
2 SOUR @S0635@
3 DATA
4 TEXT Marriage date: 29 Dec 1953 Marriage place: Cook County, IL
1 SEX F
1 BIRT
2 DATE 30 MAY 1935
2 PLAC Minneapolis, Hennepin, Minnesota, USA
2 SOUR @S0045@
3 DATA
4 TEXT Birth date: 30 May 1935 Birth place: Hennepin, Minnesota
2 SOUR @S0131@
3 PAGE Source Citation: Year: 1940; Census Place: Faribault, Rice, Minnesota; Roll: T627_1953; Page: 8B; Enumeration District: 66-9A
3 DATA
4 TEXT residence date: 1 Apr 1940 residence place: Faribault, Rice, Minnesot
5 CONC a, United States birth date: May 30, 1935 birth place: Minneapolis
5 CONC , Hennepin, Minnesota, USA Name: Joan Adrienne Hatch
3 NOTE @N0125@
1 DEAT
2 DATE 14 DEC 1989
2 PLAC Nyack, Rockland, New York, USA
1 RESI
2 DATE 1 APR 1940
2 PLAC Faribault, Rice, Minnesota, USA
2 SOUR @S0131@
3 PAGE Source Citation: Year: 1940; Census Place: Faribault, Rice, Minnesota; Roll: T627_1953; Page: 8B; Enumeration District: 66-9A
3 DATA
4 TEXT residence date: 1 Apr 1940 residence place: Faribault, Rice, Minnesot
5 CONC a, United States birth date: May 30, 1935 birth place: Minneapolis
5 CONC , Hennepin, Minnesota, USA Name: Joan Adrienne Hatch
3 NOTE @N0127@
1 RESI
2 DATE 1 APR 1940
2 PLAC Faribault, Rice, Minnesota, USA
2 SOUR @S0131@
3 PAGE Source Citation: Year: 1940; Census Place: Faribault, Rice, Minnesota; Roll: T627_1953; Page: 8B; Enumeration District: 66-9A
3 DATA
4 TEXT residence date: 1 Apr 1940 residence place: Faribault, Rice, Minnesot
5 CONC a, United States birth date: May 30, 1935 birth place: Minneapolis
5 CONC , Hennepin, Minnesota, USA Name: Joan Adrienne Hatch
3 NOTE @N0129@
1 FAMC @F1196@
1 FAMS @F0129@
1 FAMS @F0260@
1 CHAN
2 DATE 31 MAR 2017
3 TIME 22:03:40";
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