ConfirmMatch

ConfirmMatch[expr,form]

confirms that expr matches the pattern form, otherwise throwing a Failure to the nearest lexically surrounding Enclose.

ConfirmMatch[expr,form,info]

if expr does not match form, evaluates info and includes the result in the thrown Failure.

ConfirmMatch[expr,form,info,tag]

uses the tag tag for any thrown errors.

更多信息

  • expr is returned unchanged if it does not represent a error.
  • The default value of info is Null.

范例

基本范例  (2)

Confirm that a expression matches a pattern, stopping evaluation if it does:

Create a function that throws an error when given an unexpected input:

Wolfram Research (2020),ConfirmMatch,Wolfram 语言函数,https://reference.wolfram.com/language/ref/ConfirmMatch.html.

文本

Wolfram Research (2020),ConfirmMatch,Wolfram 语言函数,https://reference.wolfram.com/language/ref/ConfirmMatch.html.

CMS

Wolfram 语言. 2020. "ConfirmMatch." Wolfram 语言与系统参考资料中心. Wolfram Research. https://reference.wolfram.com/language/ref/ConfirmMatch.html.

APA

Wolfram 语言. (2020). ConfirmMatch. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/ConfirmMatch.html 年

BibTeX

@misc{reference.wolfram_2025_confirmmatch, author="Wolfram Research", title="{ConfirmMatch}", year="2020", howpublished="\url{https://reference.wolfram.com/language/ref/ConfirmMatch.html}", note=[Accessed: 05-February-2025 ]}

BibLaTeX

@online{reference.wolfram_2025_confirmmatch, organization={Wolfram Research}, title={ConfirmMatch}, year={2020}, url={https://reference.wolfram.com/language/ref/ConfirmMatch.html}, note=[Accessed: 05-February-2025 ]}