You'll probably have to do something with regexp recursion on curly braces within a class definition to replace each class definition with an empty string, thus leaving the remaining text to be all the code not within class definitions.
Possibly easier, depending on what you need this for, is to simply open the file in an editor that does "code folding", search on each instance of "class", and fold that class definition. 🙂