confirms that expr matches the pattern form, otherwise throwing an error to the nearest surrounding Enclose.


evaluates info and includes its value in the thrown error if expr is not confirmed.


uses the specified tag for any thrown errors.


  • ConfirmMatch[expr,] returns expr if expr is successfully confirmed.
  • ConfirmMatch is dynamically scoped when given a tag. Otherwise, it is lexically scoped. »
  • The default value of info is Null.
  • Failure objects generated by ConfirmMatch include the following fields:
  • "Information"info from ConfirmMatch[expr,form,info,]
    "Expression"expr from ConfirmMatch[expr,]
    "Pattern"form from ConfirmMatch[expr,form,]
  • Values of these fields can be extracted using failure["prop"] or directly through Enclose[expr,"prop"].


open allclose all

Basic Examples  (2)

ConfirmMatch[expr,form] gives expr if expr matches form:

Since "foo" does not match _Integer, ConfirmMatch stops evaluation and throws an error to the surrounding Enclose:

Create a function that checks its arguments:

Scope  (3)

ConfirmMatch stops evaluation and returns to the matching Enclose when it throws an error:

info is only evaluated when expr cannot be confirmed:

Create a function that calls ConfirmMatch with a tag so that it can be caught dynamically:

If no tag is given, ConfirmMatch is lexically scoped:

Applications  (1)

Print a message when a failure is detected:

Properties & Relations  (1)

ConfirmMatch can be emulated by ConfirmBy and MatchQ:

Possible Issues  (3)

ConfirmMatch must be given a tag or be within a lexical Enclose:

Untagged ConfirmMatch works by replacing instances of the symbol ConfirmMatch with a tagged variant:

Tagged ConfirmMatch requires an Enclose with a matching tag:

Wolfram Research (2020), ConfirmMatch, Wolfram Language function,


Wolfram Research (2020), ConfirmMatch, Wolfram Language function,


Wolfram Language. 2020. "ConfirmMatch." Wolfram Language & System Documentation Center. Wolfram Research.


Wolfram Language. (2020). ConfirmMatch. Wolfram Language & System Documentation Center. Retrieved from


@misc{reference.wolfram_2024_confirmmatch, author="Wolfram Research", title="{ConfirmMatch}", year="2020", howpublished="\url{}", note=[Accessed: 23-July-2024 ]}


@online{reference.wolfram_2024_confirmmatch, organization={Wolfram Research}, title={ConfirmMatch}, year={2020}, url={}, note=[Accessed: 23-July-2024 ]}