Search for word in text file that has space before it

I know how to use textfile.tostring.contains to search but how do I look for a specific word. Like, textfile.tostring.contains("bat) will result in battles and bat both being answers, how do I make only bat show up?

1 Like

Like this

Cheers @sparkplug93

does it work with toupper?

Yah it would but like this

Cheers @sparkplug93

if you want to only find “bat” and not “battles” then search like this:
myString.Contains(" bat ")

What if a sentence starts with word bat
In that case how this will work buddy
myString.Contains(" bat ")


well it would be a very silly sentence, but your answer works even less :slight_smile:
regex would be better to find in all cases:

Regex.IsMatch(MyFullTextVariable, "\b" + Regex.Escape("bat") + "\b")

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.