I have two strings and I want to find all the common words. For example,
s1 = 'Today is a good day, it is a good idea to have a walk.'
s2 = 'Yesterday was not a good day, but today is good, shall we have a walk?'
Consider s1 matches s2
'Today is' matches 'today is' but 'Today is a' does not match any characters in s2. Therefore, 'Today is' is one of the common consecutive characters. Similarly, we have 'a good day', 'is', 'a good', 'have a walk'. So the common words are
common = ['today is', 'a good day', 'is', 'a good', 'have a walk']
Can we use regular expression to do that?
Thank you very much.