Naming Pieces of Patterns
Particularly when you use transformation rules, you often need to name pieces of patterns. An object like x_ stands for any expression, but gives the expression the name x. You can then, for example, use this name on the right‐hand side of a transformation rule.
Thus f[x_,x_] can only stand for expressions in which the two arguments of f are exactly the same. f[_,_], on the other hand, can stand for any expression of the form f[x,y], where x and y need not be the same.
The Wolfram Language allows you to give names not just to single blanks, but to any piece of a pattern. The object x:pattern in general represents a pattern which is assigned the name x. In transformation rules, you can use this mechanism to name exactly those pieces of a pattern that you need to refer to on the right‐hand side of the rule.
|x_||any expression, to be named x|
|x:pattern||an expression to be named x, matching pattern|