Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Determine whether an input expression contains one or more subexpressions (at any level) matching a given pattern
ResourceFunction["ContainsQ"][pattern] is an operator form of ResourceFunction["ContainsQ"] that can be applied to an expression. |
Test a basic expression for the presence of a given pattern:
In[1]:= | ![]() |
Out[1]= | ![]() |
Test for another pattern:
In[2]:= | ![]() |
Out[2]= | ![]() |
ContainsQ includes heads in the subexpressions it tests against pattern:
In[3]:= | ![]() |
Out[3]= | ![]() |
ContainsQ counts matches at levelspec 0 (the full expression):
In[4]:= | ![]() |
Out[4]= | ![]() |
Wolfram Language 11.3 (March 2018) or above
This work is licensed under a Creative Commons Attribution 4.0 International License