using System.Text.RegularExpressions;
static string StripLinefeeds(Match m)
return x.Replace("\n", "");
public static void Main()
Regex re = new Regex(@""".+?""", RegexOptions.Singleline);
MatchEvaluator me = new MatchEvaluator(StripLinefeeds);
string text = "\n\"this is some text \n this should not be on the new line\"";
text = re.Replace(text, me);
text = "\n\"this is some \n text \n\n\n this should not be \n\n on the new line\"";
text = re.Replace(text, me);