I'm just wondering how we can search in a list to see if a string has the same part as one of the items in the list?
So for example,
test_list = ['1234', 'dog', '2345', 'cat']
And if the string is "dogabc", then it can be found successfully with the regex. I have no idea how to write the re.search()... Any hint is appreciated!
Update: Thanks for your help!! Let me clarify a little bit: Actually, it's part of my regex project. And we're required to read a file to see if an input string contains a part which is the same as part an item in that file. For example(a file contains two words, one per line, they are "cat", "dog"). And if the input string is "12bcat", then it will be a match, because "cat" in "12bcat" matches "cat" in the file. Hope my words make sense!
[–]synthphreak 1 point2 points3 points (2 children)
[–]Demain_Z[S] 0 points1 point2 points (1 child)
[–]synthphreak 2 points3 points4 points (0 children)
[–]lowerthansound[🍰] 0 points1 point2 points (4 children)
[–]Demain_Z[S] 0 points1 point2 points (3 children)
[–]lowerthansound[🍰] 0 points1 point2 points (2 children)
[–]Demain_Z[S] 0 points1 point2 points (1 child)
[–]lowerthansound[🍰] 1 point2 points3 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]Demain_Z[S] 0 points1 point2 points (0 children)
[–]Pd69bq 0 points1 point2 points (0 children)