0

I want to remove all the comments from my VB.NET project (in VS 2010) using regex through Find & Replace. I have already referred to these 2 questions:

But, the problem is my project has numerous lines of code which looks like this:

    Const SQLQuery As String = "Select Distinct * from [TableName] where Field='N' and Field1=@Field order by Field"

By using the solutions mentioned in the links, parts of the lines after ' (single quote) too gets eliminated, which shouldn't be happening.

Also, when I used the regex

(?mn)^(?<line>[^\r\n"R']*(("[^"]*"|(?!REM)R)[^\r\n"R']*)*)(REM|')[^\r\n]*

provided in an answer on link no 1, Visual Studio throws an error called "Argument is missing in the pattern". Now I am assuming the above mentioned regex needs to be executed through a macro or something and by passing some parameters, but I have no clue about it.

4
  • Not sure if this is the problem, but VS2010 has a bastardized regex syntax, its not like pcre. Commented Jul 27, 2015 at 17:51
  • Consider a use of Roslyn to remove the comments. Example in C#. Commented Jul 27, 2015 at 20:09
  • @Jeremy not sure what you wanted to ask! Commented Jul 28, 2015 at 3:19
  • @sln Buddy I've no idea about regex, could you please help me out with this! Commented Jul 28, 2015 at 3:29

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.