Jump to content
Guest

Comments cleanup tool

Recommended Posts

If someone is interesting in source code:

using System;
using System.IO;
using System.Text.RegularExpressions;

internal class a
{
  private static string b(string A_0)
  {
    string pattern = "(@(?:\"[^\"]*\")+|\"(?:[^\"\\n\\\\]+|\\\\.)*\"|'(?:[^'\\n\\\\]+|\\\\.)*')|//.*|/\\*(?s:.*?)\\*/";
    return Regex.Replace(A_0, pattern, "$1");
  }

  private static string aa(string A_0)
  {
    return Regex.Replace(A_0, "^\\s+$[\\r\\n]*", "", RegexOptions.Multiline);
  }

  private static void Main(string[] A_0)
  {
    Console.Title = "Comments removal tool - Rtz";
    Console.WriteLine("Please enter the path to the file:\n");
    try
    {
      string path = Console.ReadLine();
      string contents = a.aa(a.b(File.ReadAllText(path)));
      File.WriteAllText(path, contents);
      Console.WriteLine("\nAll comments were successfully removed from - " + path);
      Console.WriteLine("\nPress any key to exit");
    }
    catch (Exception ex)
    {
      Console.WriteLine(Environment.NewLine + ex.Message);
    }
    Console.ReadKey();
  }
}

 

Share this post


Link to post
Share on other sites
2 hours ago, Lua said:

any1 got a new link for this?

 

On 10/23/2016 at 12:28 AM, Wrexor said:

If someone is interesting in source code:


using System;
using System.IO;
using System.Text.RegularExpressions;

internal class a
{
  private static string b(string A_0)
  {
    string pattern = "(@(?:\"[^\"]*\")+|\"(?:[^\"\\n\\\\]+|\\\\.)*\"|'(?:[^'\\n\\\\]+|\\\\.)*')|//.*|/\\*(?s:.*?)\\*/";
    return Regex.Replace(A_0, pattern, "$1");
  }

  private static string aa(string A_0)
  {
    return Regex.Replace(A_0, "^\\s+$[\\r\\n]*", "", RegexOptions.Multiline);
  }

  private static void Main(string[] A_0)
  {
    Console.Title = "Comments removal tool - Rtz";
    Console.WriteLine("Please enter the path to the file:\n");
    try
    {
      string path = Console.ReadLine();
      string contents = a.aa(a.b(File.ReadAllText(path)));
      File.WriteAllText(path, contents);
      Console.WriteLine("\nAll comments were successfully removed from - " + path);
      Console.WriteLine("\nPress any key to exit");
    }
    catch (Exception ex)
    {
      Console.WriteLine(Environment.NewLine + ex.Message);
    }
    Console.ReadKey();
  }
}

 

just build it in vs 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×