I want to check whether a particular string is present in a sentence. I am using simple code for this purpose
subStr = 'joker'
Sent = 'Hello World I am Joker'
if subStr.lower() in Sent.lower():
print('found')
This is an easy straightforward approach, but it fails when sentence appears as
hello world I am Jo ker
hello world I am J oker
As I am parsing sentence from a PDF
file some unnecessary spaces are coming here and there.
A simple approach to tackle this issue would be to remove all the spaces from a sentence and look for a substring match. I want to know other peoples thoughts on this, should I stick with this approach or look for some other alternatives.