Reputation: 2421
(VB.NET, .NET 3.5)
I'm trying to write a function to find a word in a string in the this format : "ThisissometextthatIneedtofindandthisisthetext. This is another text."
It's read as " This is some text that I need to find and this is the text. This is another text." but there is no space between each word. I want to get the word "text" or any word in that string. Can you help me with this function with a code sample ?
And I think that this method can be implemented with a string of Unicode also because in a sentence of Unicode it contains one or few, sometimes zero spaces between each word.
Thanks.
Upvotes: 0
Views: 679
Reputation: 3914
To test if a substring exist in a string or unicode, you could use:
exists = InStr"ThisissometextthatIneedtofindandthisisthetext. This is another text.", "text") <> 0
Upvotes: 0
Reputation: 16129
I would look up articles on spell checkers. This is a decent one. I would expect the two problems have very similar solutions.
Upvotes: 0
Reputation: 125689
See String.IndexOf(). It does exactly what you want.
Actually, after trying to find it in the help file, I've reconsidered my response to your question in the comments. See MSDN for examples and documentation. (Finding it, as simple as it should have been, wasn't so simple. :-)
Upvotes: 0