Question: I need to search a string for a list of several different matches, let's say I have this list:

```
['this', 'is', 'a', 'regex', 'test']

```

I want to see if any of those items is within a string, either using regex or any other method in Python.

I tried first just doing `string in list`, but that proved to be insufficient, so I tried concatenating the conditions in a regex like:

```
(this|is)(a|regex)(text)

```

But that tries to match several of the items as if they were concatenated.

Answer: 
You can use the built-in function `any()`:

```
In [1]: strs="I am a string"

In [2]: lis=['this', 'is', 'a', 'regex', 'test']

In [3]: any(x in strs for x in lis)
Out[3]: True

```

This will return `True` for something like `"thisisafoobar"` as well.

But if you want to match the exact word, then try `re.search()` or `str.split()`:

```
In [4]: import re

In [5]: any(re.search(r"\b{0}\b".format(x),strs) for x in lis)
Out[5]: True

In [6]: strs="foo bar"

In [7]: any(re.search(r"\b{0}\b".format(x),strs) for x in lis)
Out[7]: False

```

Using `str.split()`:

```
In [12]: strs="I am a string"

In [13]: spl=strs.split()    #use set(strs.split()) if the list returned is huge

In [14]: any(x in spl for x in lis)
Out[14]: True

In [15]: strs="Iamastring"

In [16]: spl=strs.split()

In [17]: any(x in spl for x in lis)
Out[17]: False

```
You could do:

```
if any(test in your_string for test in tests):
    ...

```