Skip to content

Instantly share code, notes, and snippets.

@kppullin
Last active August 29, 2015 14:13
Show Gist options
  • Save kppullin/18c6d6605b71216df5a1 to your computer and use it in GitHub Desktop.
Save kppullin/18c6d6605b71216df5a1 to your computer and use it in GitHub Desktop.
Create multiline Java string using C# + Linqpad
var s = @"SELECT *
FROM TABLE
WHERE ID = @ID
";
var sb = new StringBuilder();
var lines = Regex.Split(s, "\n");
for (int i = 0; i < lines.Length; ++i)
{
var line = lines[i];
if (i == lines.Length - 1 && line.Trim().Length == 0)
continue;
sb.Append("\"" + Regex.Replace(line, "[\r\n]", "") + "\\n\" +\n");
}
sb.Length -= 3;
sb.ToString().Dump();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment