How to extract mathematica output

The output to my mathematica cell is just a long algebraic equation produced from `Solve[%, Subscript[u, i, j + 1]]`.

``{{Subscript[u, i, 1 + j] -> (1/(2 h^2))(-2 h^2 k Subscript[f, i, j] + 2 h^2 Subscript[u, i, j] +2 b h^2 k Subscript[u, i, j] -h k Subscript[u, -1 + i, j] Subscript[\[Mu], i, j] +h k Subscript[u, 1 + i, j] Subscript[\[Mu], i, j] +2 k Subscript[u, -1 + i, j] Subscript[\[Sigma], i, j] -4 k Subscript[u, i, j] Subscript[\[Sigma], i, j] +2 k Subscript[u, 1 + i, j] Subscript[\[Sigma], i, j])}}``

I want to collect the terms \$u_{i,j}\$ on the right side of this expression, but I dont know how to get a handle on the output of Solve[]. i.e I want to do something like

``Collect[%, {Subscript[u, i, j - 1], Subscript[u, i, j], Subscript[u,i, j + 1]}]``

But here % doesn't quite do the trick. Any ideas on how I might achieve this?

Mathematica returns the nested list, because in general there will be multiple solutions with multiple variables.

The most robust way of extracting the RHS of a replacement rule is to actually use it, e.g.

``````In:= x/.Solve[x - m b - m c == 0,x]
Collect[First[%],m]
Out= {b m + c m}
Out= (b + c) m
``````

That said, the command Part[] (or [[]]) can take more than one argument, so it does not need to be repeated:

``````In:= Solve[x-m b-m c==0,x]
Collect[%[[1,1,2]],m]
Out= {{x->b m+c m}}
Out= (b + c) m
``````

If figured it out, Mathematica returns nested lists, which can be accessed by %[][]