Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Fixing Broken Lines with Regex
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; // aljodav // http://rextester.com/users/376 namespace Rextester { using BrokenLines=Rextester.Program; public class Program { public static void Main(string[] args) { // *********************************************** string allLines=string.Empty,line; while((line=Console.ReadLine())!=default(string)){ allLines+=line+"\r\n"; } // long line's just built ************************ //Console.WriteLine(allLines); Console.WriteLine(new BrokenLines().Fix(allLines)); // that's all } public string Fix(string s){ return Regex.Replace(s,"\"|\r\n",new MatchEvaluator(Fix)); } private int _count=0; private string Fix(Match m){ if(m.Value=="\""){++_count;return m.Value;} return _count%2==1?string.Empty:m.Value; } } }
run
|
edit
|
history
|
help
0
Sandeep Chandra Bose
test code
input
first
Everyone can sen ,only me can edi
Swiss Infotech Tutorial
Encapsulation and abstration
532
world
code1