问题
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