using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"(\S)[ \t]*(?:\r\n|\n)[ \t]*(\S)";
string substitution = @"\1 \2";
string input = @"Random Data, Company
2015
This is a sentence that has line
break in the middle of it due to extracting from a PDF.
How do I support
3 line sentence
breaks please?
HEADER HERE
The first sentence will
match. However, this line will not match
for some reason
that I cannot figure out.
Portfolio:
http://DoNotMatchMeBecauseIHaveAPeriodInMe.com
Full Name
San Francisco, CA
94000
1500 testing a number as the first word in
a broken sentence.
Match sentences with capital letters on the next line like
Wi-Fi.
This line has
trailing spaces after exclamation mark!
";
Regex regex = new Regex(pattern);
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