Maybe you've already considered it, but "substringing" like this feels like a bit of a hack.
It was a long time ago that I was looking in the parameter expander, but If there isn't a way already to get the variables from the first pass I guess it would be better to refactor that class to first expand everything needed into some data structure and then either use that data here or do the next pass to create the command.