fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text.RegularExpressions;
  6.  
  7. public class Test
  8. {
  9. public static void Main()
  10. {
  11. var text = "int rn = 0; //comment1.0\r\n" +
  12. "int r = 0; //comment2.\r" +
  13. "int n = 0; //comment3.\n" +
  14. "end";
  15. Console.WriteLine(RemoveLineEndComment(text));
  16. }
  17.  
  18. public static string RemoveLineEndComment(string text)
  19. {
  20. var RegexRemoveLineEndComment = new Regex(@"\s*//[^\r\n]*", RegexOptions.Multiline);
  21. return RegexRemoveLineEndComment.Replace(text, string.Empty);
  22. }
  23. }
Success #stdin #stdout 0.06s 27424KB
stdin
Standard input is empty
stdout
int rn = 0;
int r = 0;
int n = 0;
end