Remove all comments from VB.NET source code file

流过昼夜 提交于 2019-12-06 09:47:47

问题


Is there a macro in the Visual Studio editor to remove all comments from a VB.NET source file?


回答1:


Using menu Edit -> Find and Replace -> Quick Replace with Regular expressions

Find what: ^{.+}'.+$

Replace with: \1

will replace

text ' comment

to

text



回答2:


EDIT*

http://bytes.com/topic/visual-basic-net/answers/579000-utility-remove-comments-vb-net-files

has some options.

such as

  • write a VB.NET program to do it? should be easy: any line with a single quote as the first character should be removed. and everything AFTER a single quote (even if it's not the first character), provided the quote is not between a pair of double quotes. and the files you send to this program are any *.vb files.
  • search and replace with a regular expression would probably be quickest.



回答3:


Find: ^{(([^"']*"[^"]*"[^"'])#|[^"']*)}'.*$

Replace with \1
will also work for stuff like this (SQL):

   cs = "INSERT INTO db (time, t1, t2) VALUES ('" & Time.ToString & "', NULL, '" & t2 & "')" ' COMMENT


来源:https://stackoverflow.com/questions/2563202/remove-all-comments-from-vb-net-source-code-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!