Using the objects described in "Introduction to Patterns", you can set up patterns for many kinds of expressions. In all cases, you must remember that the patterns must represent the structure of the expressions in the Wolfram Language internal form, as shown by FullForm.
Especially for some common kinds of expressions, the standard output format used by the Wolfram Language is not particularly close to the full internal form. But it is the internal form that you must use in setting up patterns.
The rule picks out each piece of the complex numbers:
The fact that these expressions have different full forms means that you cannot use x_+Iy_ to match a complex number:
The pattern here matches both ordinary integers, and complex numbers where both the real and imaginary parts are integers:
As discussed in "Symbolic Computation", the Wolfram Language puts all algebraic expressions into a standard form, in which they are written essentially as a sum of products of powers. In addition, ratios are converted into products of powers, with denominator terms having negative exponents, and differences are converted into sums with negated terms. To construct patterns for algebraic expressions, you must use this standard form. This form often differs from the way the Wolfram Language prints out the algebraic expressions. But in all cases, you can find the full internal form using FullForm[expr].
Here is a typical algebraic expression:
This is the full internal form of the expression:
This is what you get by applying a transformation rule to all powers in the expression: