({{, (RefLink[HoldPattern, paclet:ref/HoldPattern])[expr]
is equivalent to expr for pattern matching, but maintains expr in an unevaluated form. }})

OpenersNotesSection(Spacer1)Details

(RefLink[HoldPattern, paclet:ref/HoldPattern]) has attribute (RefLink[HoldAll, paclet:ref/HoldAll]).

The left-hand sides of rules are usually evaluated, as are parts of the left-hand sides of assignments. You can use (RefLink[HoldPattern, paclet:ref/HoldPattern]) to stop any part from being evaluated.

OpenersPrimaryExamplesSection(Spacer1)Examples  (4)

OpenersExampleSection0(Spacer1)Basic Examples  (4)

Set up a pattern whose left-hand side is kept unevaluated:

HoldPattern[_+_]->0

Use the pattern:

a+b/.%

Make a definition without the argument of f being evaluated:

f[HoldPattern[_+_]]:=0

f[a+b]

(RefLink[Log, paclet:ref/Log])[a,b] autoevaluates to (RefLink[Log, paclet:ref/Log])[b]/(RefLink[Log, paclet:ref/Log])[a], so there is a match:

MatchQ[Log[a,b],HoldPattern[Log[_]/Log[_]]]

(RefLink[Cases, paclet:ref/Cases])[e,patt->rhs] finds elements that match patt; use (RefLink[HoldPattern, paclet:ref/HoldPattern]) to find rules:

Cases[{a->b,c->d},HoldPattern[a->_]]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[Hold, paclet:ref/Hold])  ▪  (RefLink[Verbatim, paclet:ref/Verbatim])  ▪  (RefLink[Unevaluated, paclet:ref/Unevaluated])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Patterns and Transformation Rules, paclet:tutorial/PatternsAndTransformationRules])}, {▪(RefLinkPlain[Evaluation, paclet:tutorial/Evaluation])}, {▪(RefLinkPlain[Evaluation in Patterns, Rules and Definitions, paclet:tutorial/EvaluationInPatternsRulesAndDefinitions])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Evaluation Control, paclet:guide/EvaluationControl])}, {▪(RefLinkPlain[Patterns, paclet:guide/Patterns])}})}})