Click here to Skip to main content
15,890,399 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi everybody!

i am using vb6 for read a vb file, and get all comments in vb file. how can i do it using regular expression in vb6.?


thanks :)
Posted

Load your source file line by line, and test each line. What you want is to take everything after either ' or REM.

I'm not sure of the exact Regex, I'm afraid. My approach would be to open the source and read it character by character, taking everything between a comment indicator and the end of the line.
 
Share this answer
 
To be honest, I wouldn't - a regex is a fairly dumb object and is good at string matching, but it's pretty useless when it comes to complex stuff:
VB
Dim myVar as String = "It's going wrong!" 'Oh yes it is! It's wrong, wrong, wrong...


Instead I'd look at a more sophisticated parser, but why do you want to do that anyway - there may be a better way to do it.
 
Share this answer
 
Comments
kakavn 12-Feb-14 9:51am    
i want to use regular like this "(/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/)|(//.*)". this is Regex for get all comment in Java source code.

how can't i get all comment in file .vb using Regex ??

Help me :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900