Visual Studio regex to remove all comments and blank lines in VB.NET code using a macro

后端 未结 3 1571
长情又很酷
长情又很酷 2021-01-14 00:57

I was trying to remove all comments and empty lines in a file with the help of a macro. Now I came up with this solution which deletes the comments(there is some bug descri

3条回答
  •  迷失自我
    2021-01-14 01:27

    Delete the comments first using this regex

    '+\s*(\W|\w).+

    '+ - one or more ' for the beginning of each comment.

    \s* - if there are spaces after the comment.

    (\W|\w).+ - anything that follows except for line terminators.

    Then remove the blank lines left using the regex Mr. Alan Moore provided.

提交回复
热议问题