I have a function that I am defining as (assume m,n,a,b are non-negative integers):
myfcn[x_^m_ p_^n_, x_^a_ p_^b_] := basefcn[m, n, a, b];
and then extending to all polynomials by linearity.
The way I defined the function above works as long as m,n,a,b are all greater than 1, but fails otherwise. For instance, I want myfcn[x p^2, p] to evaluate to basefcn[1,2,0,1], but mathematica does not recognize that this is what I want.
How do I extend my function definition to include these cases without explicitly writing out all possible input forms?
Thanks.

Optional. You win this time. However, you do not need to use e.g.(m_: 1)asm_.will do since1is the default value forPower. This significantly streamlines your code. See: (51585) – Mr.Wizard Aug 20 '14 at 03:54xandpin your function whereas by my interpretation of the question these are arbitrary symbols or expressions. – Mr.Wizard Aug 20 '14 at 03:56_.tip! Could I edit my post to add that in? Also, the reason I chose to use explicitxandpis because the function the OP defines (withx_andp_) is ambiguous. For example, using OP's definition,myfunc[x^2, p^3]could be matched such thatx^2matchesx_^m_, andp^3matchesp_^b_. However,x^2could just as well match withp_^n_, andp^3withx_^a_, sincex_andp_in OP's definition could be anything. Please let me know if I might be confused on that point. – seismatica Aug 20 '14 at 04:12Optionalwould be better/more elegant than mine. – seismatica Aug 20 '14 at 04:17xandpbetter addressed. – Mr.Wizard Aug 20 '14 at 05:01