# Odd behavior matching powers of pi

I have a long list of generated values from which I want to remove "weird" ones like Sin[Sin[1]] and Pi^2/4. However, trying to remove the powers of Pi fails on this value:

MatchQ[Sqrt[2 Pi], (_ Pi)^_] (* False *)


The FullForm of the expression is

Power[Times[2, Pi], Rational[1, 2]]


I can only match the expression when I explicitly specify the 2:

 (_Integer Pi)^_  (* False *)
(2 Pi)^_         (* True *)


What's going on here?

• I found out what's happening, but I don't know why it's happening. Points to anyone who can explain. – 2012rcampion Feb 22 '15 at 21:08
• An interesting question would be: when does (x y)^power automatically split into x^power y^power and when does it stay together? – Szabolcs Feb 22 '15 at 21:59

 Pi^_*_^_

Using HoldPattern prevents this behavior and gives the expected result:
MatchQ[Sqrt[2 Pi], HoldPattern[(_ Pi)^_]] (* True *)

• Interesting! I would not have hit me, that the Power-rules are applied even for patterns. Good find! – Jinxed Feb 23 '15 at 1:00