Thanks Carl. I was looking for something that could be done automatically, and maybe one way is to use CellPrint and then a NotebookImport to get the Input cells.
Also thanks Data Computist. Apparently MakeExpression is making an ExpressionCell object, which presumably is something that can be ignored.
I guess that MakeExpression is an old function, while AllCases is a new one (which could replace Cases[…,Infinity])
Todd I will also post an answer that I got from some folks, so just being the messenger here.
There’s no guarantee that a particular RawBoxes or Cell represents a valid WL expression. But if it did, then yes, MakeExpression would be the low-level way to extract it. (See also: StripBoxes.) For example:
Thanks everyone. I woke up in the middle of the night realizing that NotebookImport[Notebook[AllCases[expr,_Cell]] would work. Only learned about NotebookImport a few days ago although it’s been around for a couple years.