The problem I have is that I am using isInfixOf on a string below to check whether the word I am looking for is within the string, the below works up to a certain point.
> "world" `isInfixOf` "hello world"
True
but what if it’s part of another word it still returns TRUE as below:
> "wor" `isInfixOf` "hello world"
True
I am trying to find out whether the word passed in is in the string I am looking for but it is not part of another song.
I have tried a lot of methods but I am not sure how I could make sure the word is not part of a another word.
WORDS does not work because it doesn’t strip the string of it’s punc character.
Some regular expression packages could be helpful here.
For example, using regex-prce-builtin.
\\bstands for\bword boundary, which is used in Perl regular expressions.So we can define new
isInfixOfanalogue using(=~).