MatchQ

MatchQ[expr,form]

returns True if the pattern form matches expr, and returns False otherwise.

MatchQ[form]

represents an operator form of MatchQ that can be applied to an expression.

Details

Examples

open allclose all

Basic Examples  (3)

Test if an expression is an integer:

In[1]:=
Click for copyable input
Out[1]=

Test if an expression is a sum of two or more terms:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=

Test if an expression is explicitly zero:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=

Scope  (10)

See Also

StringMatchQ

Tutorials

Introduced in 1988
(1.0)
| Updated in 2014
(10.0)