Use replacement rule for this named pattern?

Suppose I have two systems of coordinates:{x1,x2} and {y1,y2}. I want to transform an expression containing \frac{\partial yi}{\partial xj}'s to those in terms of \frac{\partial xj}{\partial yi}'s. I wrote the following code:

expr = D[y2[x1, x2], {x1, 2}, {x2, 0}] + D[y1[x1, x2], {x1, 0}, {x2, 2}];
expr /. Derivative[n_, m_][y : y1 | y2][x1, x2] -> Nest[(1/\!\(
\*SubscriptBox[\(\[PartialD]\), \(y1\)]\(x2[y1, y2]\)\) \!\(
\*SubscriptBox[\(\[PartialD]\), \(y1\)]\((#)\)\) + 1/\!\(
\*SubscriptBox[\(\[PartialD]\), \(y2\)]\(x2[y1, y2]\)\) \!\(
\*SubscriptBox[\(\[PartialD]\), \(y2\)]\((#)\)\)) &, Nest[(1/\!\(
\*SubscriptBox[\(\[PartialD]\), \(y1\)]\(x1[y1, y2]\)\) \!\(
\*SubscriptBox[\(\[PartialD]\), \(y1\)]\((#)\)\) + 1/\!\(
\*SubscriptBox[\(\[PartialD]\), \(y2\)]\(x1[y1, y2]\)\) \!\(
\*SubscriptBox[\(\[PartialD]\), \(y2\)]\((#)\)\)) &, 1/\!\(
\*SubscriptBox[\(\[PartialD]\), \(y\)]\(x1[y1, y2]\)\), n], m]

Why is this not working? It seems n,m and y are not recognized in the RHS of my replacement rule.

Is it this what you want ( :> instead of → in your rule) ?

expr /. Derivative[n_, m_][y : y1 | y2][x1, x2] :> Nest[(1/\!\(
\*SubscriptBox[\(\[PartialD]\), \(y1\)]\(x2[y1, y2]\)\) \!\(
\*SubscriptBox[\(\[PartialD]\), \(y1\)]\((#)\)\) + 1/\!\(
\*SubscriptBox[\(\[PartialD]\), \(y2\)]\(x2[y1, y2]\)\) \!\(
\*SubscriptBox[\(\[PartialD]\), \(y2\)]\((#)\)\)) &, Nest[(1/\!\(
\*SubscriptBox[\(\[PartialD]\), \(y1\)]\(x1[y1, y2]\)\) \!\(
\*SubscriptBox[\(\[PartialD]\), \(y1\)]\((#)\)\) + 1/\!\(
\*SubscriptBox[\(\[PartialD]\), \(y2\)]\(x1[y1, y2]\)\) \!\(
\*SubscriptBox[\(\[PartialD]\), \(y2\)]\((#)\)\)) &, 1/\!\(
\*SubscriptBox[\(\[PartialD]\), \(y\)]\(x1[y1, y2]\)\), n], m]

Thanks. This fix works!