When I prepare an exercise list for my students I use to also include there my own solutions. I prepare these documents with some macros based on mdframed and with comment help I easily obtain two pdfs, one with exercises and another one with exercises and solutions.
I encourage my students to try to write their solutions with LaTeX so I give them the .pdf file with exercises and a source .tex file without answers. This way, they only have to worry about writing their solutions because the format is already provided. The problem is that I need to have two source files one with problems+solutions and another one only with problems.
What I would like would be to have only one .tex file with problems and solutions and, from it be able to extract another .tex file without solutions. As a possible frame work suppose a main .tex file like:
% This is main.tex file
\documentclass{article}
\begin{document}
\begin{exercise}
This is the first exercise
\begin{solution}
This is my solution
\end{solution}
\end{exercise}
\end{document}
from which I want to easily obtain a similar one with empty solutions:
% This is student.tex file
\documentclass{article}
\begin{document}
\begin{exercise}
This is the first exercise
\begin{solution}
\end{solution}
\end{exercise}
\end{document}
I suppose I'm looking for something like a .dtx file but I've never used it and may be there are better solutions. I'm working on windows so grep commands won't work.

\begin{solution}and\end{solution}. But I am not sure whether an analog is possible through LaTeX itself, too. – Dominikus K. Mar 08 '13 at 15:32examdocument class? It won't give you two tex sources, but as @DominikusK. says, you can easily write a parser. – Sean Allred Mar 08 '13 at 15:51document,questions) while excluding other environments (e.g.solution). – Sean Allred Mar 08 '13 at 21:17extractpackage? – mbork Mar 08 '13 at 22:19