Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Somewhere in the code, I've forgotten std::cout<< which is now messing up my console. But my code us full of commented debug outputs and VC++ searches through all of them, making it impossible to find my problem.
I think it could be solved with the regular expression option in search dialog. Have you any idea, what pattern should I use to avoid searching cout in //comment and /*comment*/?

How to ignore comments while searching text in Microsoft Visual C++ 2010 Express?

share|improve this question

^[^/*]*std::cout<< should find any occurrence of std::cout<< that doesn’t have any slashes or asterisks to its left.  Notes: (1) If you’re using / to initiate your search, you will probably need to put a backslash before the slash in the regex.  (2) This will not find code to the right of a */.  (3) If you write multiple statements on a line, this regex will be messed up by anything in a statement to the left of the one you’re looking for.

share|improve this answer
Ad (3): Not only that, this code also will not work for // and I'm afraid it will require no spaces between comment and command. But this cold maybe fixed using [ ]*. – Tomáš Zato Mar 21 '13 at 12:06
@TomášZato: I don’t understand you. I just tested it (in vi) and it worked correctly for //, and I really have no idea what you mean by “it will require no spaces between comment and command.” I already said that my regex will not find code to the right of a */. Please explain. – Scott Mar 21 '13 at 17:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.