I want to check if a particular string is present in a sentence. I use simple code for this
subStr = 'joker' Sent = 'Hello World I am Joker' if subStr.lower() in Sent.lower(): print('found')
This is a simple approach, but it does not work when a sentence appears as
hello world I'm joyer
hello world I'm Oker
When I parse a sentence from a PDF file, unnecessary spaces appear here and there.
A simple approach to solving this problem would be to remove all spaces from the sentence and search for matching substrings. I want to know the thoughts of other peoples on this issue, should I take this approach or look for other alternatives.
source share