How to work on object to get 0,1,2,3 out of it

You could do that in a ruby filter. This post gives an example, although obviously it will require changes to the pattern and capture group references.