It most likely is impossible to parse this structure using RegEx.
It would be possible to write a specialized parser for it, but given that PHP makes no promises on its format, it is a very bad idea to do so. In a minor PHP version update the format could change and the parser would stop working.
Even more, var_dump
is lossy, that is there are cases when you can not recover the state of an object just by its representation. The simplest example would be resources. var_dump
ing an open file returns resource(5) of type (stream)
, which is completely not enough to do anything useful with it.
All in all, it just sounds like a bad idea, and whatever problem would be solved by it, should be solved differently.