Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Test if a string contains all elements from a list
ResourceFunction["StringContainsAll"][string,{patt1,patt2,…}] returns True if string contains each of the patti. | |
ResourceFunction["StringContainsAll"][{patt1,patt2,…}][string] is an operator form of ResourceFunction["StringContainsAll"] that can be applied to arguments. |
Bring up the opening of the Declaration of Independence:
In[1]:= | ![]() |
Out[1]= | ![]() |
Test to see whether the text contains the words "people", "dissolve" and "Laws":
In[2]:= | ![]() |
Out[2]= | ![]() |
Conversely, despite containing the word "human", the text does not contain all of the words "human" and "xylophone":
In[3]:= | ![]() |
Out[3]= | ![]() |
In[4]:= | ![]() |
Out[4]= | ![]() |
Define some text:
In[5]:= | ![]() |
Out[5]= | ![]() |
Use the operator form of StringContainsAll:
In[6]:= | ![]() |
Out[6]= | ![]() |
In[7]:= | ![]() |
Out[7]= | ![]() |
Find all words containing "e", "t", "l", "a" and "b" and put them in a WordCloud:
In[8]:= | ![]() |
Out[8]= | ![]() |
String patterns are case sensitive:
In[9]:= | ![]() |
Out[9]= | ![]() |
In[10]:= | ![]() |
Out[10]= | ![]() |
Use the option IgnoreCase to match upper- and lower-case letters:
In[11]:= | ![]() |
Out[11]= | ![]() |
This work is licensed under a Creative Commons Attribution 4.0 International License