AnyMatch
Details
Examples
open all close allBasic Examples (4)
Check if any element of a list matches a pattern:
AnyMatch[{x ^ 2, y ^ 3, x ^ 5, x ^ 6}, y ^ _]AnyMatch[{a, b, b, a, a, a}, _Integer]Check if any element of a matrix matches a pattern:
AnyMatch[{{a, 1, c}, {2, e, 3}}, _Integer, 2]AnyMatch[{{a, b, c}, {d, e, f}}, _Integer, 2]Use the operator form of AnyMatch:
AnyMatch[_Integer][{1, 1, f[a], 2, 3, y, f[8], 9, f[10]}]Check if any value of an association matches a pattern:
AnyMatch[<|"a" -> 1, "b" -> b, "c" -> 3|>, _Symbol]Scope (4)
AnyMatch may be applied to expressions with any head:
AnyMatch[f[a, 1, b], _Integer]AnyMatch can operate on ragged expressions:
AnyMatch[{{a, 1, c}, {2, e}}, _Integer, 2]AnyMatch[f[{a, 1, c}, {2, e}], _Integer, 2]By default, AnyMatch operates at level 1:
AnyMatch[4, _Integer]AnyMatch[{}, _Integer]AnyMatch[4, _Integer, 0]Use Verbatim to test for a literal blank:
AnyMatch[f[a, _, c], Verbatim[_]]Properties & Relations (6)
AnyMatch[list,form] is equivalent to !NoneMatch[list,form]:
{AnyMatch[{a, 1, c, 2, e}, _Integer], !NoneMatch[{a, 1, c, 2, e}, _Integer]}AnyMatch[list,form] works efficiently on sparse vectors:
AnyMatch[SparseArray[{1000 -> a}, {1000000000000}], _Symbol]//EchoTimingAnyMatch[list,form] checks the parts of list in order, stopping as soon as form matches:
AnyMatch[{1, 2, 3, 4, 5}, _ ? (EvenQ @* Echo)]AnyMatch[list,form] is equivalent to AnyTrue[list,MatchQ[form]]:
{AnyMatch[{1, 2, 3, 4, 5}, _Integer], AnyTrue[{1, 2, 3, 4, 5}, MatchQ[_Integer]]}AnyMatch[{e1,e2,…},form] is equivalent to Or[MatchQ[e1,form],MatchQ[e2,form],…]:
{AnyMatch[{a, 1, b}, _Integer], MatchQ[a, _Integer] || MatchQ[1, _Integer] || MatchQ[b, _Integer]}AnyMatch[list,e1|e2|…] is equivalent to ContainsAny[list,{e1,e2,…}]:
{AnyMatch[{a, a, b, c, a}, a | b], ContainsAny[{a, a, b, c, a}, {a, b}]}Possible Issues (1)
For associations, AnyMatch tests only values:
AnyMatch[<|a -> 1|>, 1]AnyMatch[<|a -> 1|>, a]History
Text
Wolfram Research (2024), AnyMatch, Wolfram Language function, https://reference.wolfram.com/language/ref/AnyMatch.html.
CMS
Wolfram Language. 2024. "AnyMatch." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/AnyMatch.html.
APA
Wolfram Language. (2024). AnyMatch. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/AnyMatch.html
BibTeX
@misc{reference.wolfram_2026_anymatch, author="Wolfram Research", title="{AnyMatch}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/AnyMatch.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_anymatch, organization={Wolfram Research}, title={AnyMatch}, year={2024}, url={https://reference.wolfram.com/language/ref/AnyMatch.html}, note=[Accessed: 12-June-2026]}