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.