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:
- Visual Studio regex to remove all comments and blank lines in VB.NET code using a macro
- Remove all comments from VB.NET source code file
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.