Question: Imagine if there is a list of words like `words = ["hello","boy","cool"]` and a user input of a string `string = "helloboycool"`.

My question: Is there a way to use **Regular Expression** to find all the words in the "words" list that match a part of the input "string".

For example:
`list = ["123","hello","nice","red","boy"]` and `input = "helloniceboy"`. The input string has **no spaces**.

Using the "input" string as a search term for the **regular expression**, the output should be the words `["hello","nice","boy"]` in a list form.

**Yes, I know this could be done through simple loops. However, I just trying to work on a problem that I came across while doing my office work. So, it was worth asking this question to y'all.**
Also, thanks for all the answers. They are sure helpful insights. **Overlapping is fine**

I am fairly new to the regex thing in python.

Answer: 
If you don't need to find overlapping matches, you can turn the list into a regular expression that uses `|` to match alternatives. Then use `re.findall()` to get all the matches.

```
import re

words = ["123","hello","nice","red","boy"]
string = "helloniceboy"
regex = re.compile('|'.join(re.escape(x) for x in words))
result = re.findall(regex, string)

```

`re.escape()` ensures that the words will be matched literally, even if they contain characters that have special meaning in regular expressions.

If you do need to find overlapping matches, the other answer that uses `if word in input` in a loop will work better.
Does it have to be a regex? It can be done easily like this:

```py
list = ["123", "hello", "red", "nice", "happy", "boy"]
input = "helloniceboy"

result = []
for i in list:
    if i in input:
        result.append(i)

print(result)

```

If it **has** to be regex, there is a built-in module called `re` which you can use.