Given a file like this:
'declare a string variable
Dim s as string
For x = 1 to 10
' add Hello to string
s=s+"Hello"
End for
I need a regex to strip out all the comments in the code:
Regex would return:
'declare a string variable
' add Hello to string
Note that there may be whitespace before the quote and after the quote.
If it makes a difference I am intending to run this through grep to get all comments from a bunch of *.vb files.
search for this
^\s*'^means at the beginning of the line\s*means to match as much space as possible (optionally no space)'is the comment that you’re looking forand match any lines that match that regex, and you can splice out all of the comments