# Matching variables with Subscripts yielding True and False

I am trying match variables with subscripts just returning true or false depending if pattern is matched. My try is to use Cases. However the following does not return a match

Cases[Subscript[x, 2], Subscript[x, l_] /; l > 1]


Moreover, if this would work there must something nicer than

Length[    Cases[Subscript[x, 2], Subscript[x, l_] /; l > 1]]>=1

• Cases[{Subscript[x, 2]}, Subscript[x, l_] /; l > 1] , MatchQ[Subscript[x, 2], Subscript[x, l_] /; l > 1]for just single test. – ciao Mar 26 '14 at 21:46
• MatchQ[( Subscript[x, 2])^2, _ Subscript[x, l_] _ /; l > 1] does not work, I want to check if it occurs anywhere in the term i.e. would the rule Subscript[x, l_] _ /; l > 1:> 5 change something – warsaga Mar 26 '14 at 22:05
• That's because your use of MatchQ there is a bit wacky. Perhaps clarify more precisely what you want in the OP? It seems perhaps Cases[Level[expression, Infinity], Subscript[x, l_] /; l > 1] might be what you're after. – ciao Mar 26 '14 at 23:05
• Not@FreeQ[(Subscript[x, 2])^2, Subscript[x, l_] /; l > 1]? – kglr Mar 27 '14 at 0:08

As mentioned in the comments, you can use either MatchQ:
MatchQ[Subscript[x, 2], Subscript[x, _?(# > 1 &)]]

or FreeQ with Not:
!FreeQ[Subscript[x, 2], Subscript[x, _?(# > 1 &)]]