regex - Scan a file for a string of words ignoring extra whitespaces using VB.NET -


I'm searching for a string of a word, for example "one two three" I'm using: < Phrase index = text.IndexOf (Phrase, StringComparison.OrdinalIgnoreCase) as the

  dim text string = File.ReadAllText (filepath) if the index for each phrase & gt; = 0 then end and then exit for next  

and it worked fine, but now I know that some files include the target phrases with the spacing of more than one empty space between the words It is possible.

For example, searches my code

" one two three " but fails to find " one two three "

There is a way i can use the regular expression, or any other technique to capture the word, even if the distance between words is more than one white spot?

I know that I

  dim text string = File.ReadAllText (filepath) for each phrase in the phrases text = Replace ("", "" ") Index = text.IndexOf (phrase, StringComparison.OrdinalIgnoreCase) if index & gt; = 0 then end then exit for next  

but I wanted to know what happened to E is the most effective way that

is to be completed

You can perform a function to remove any double spaces.

 Option to make a clear estimate on the option on the strict option: Public Class Form1 Handles Private Sub Form1_Load (as the object, in the form of e EventArgs) MyBase.Load as the slow testString string = String = RemoveExcessSpaces (testString) 'one two three four five to six' as the slow excessSpacesGone 'one two three four five to six clipboard.SetText (excessSpacesGone) MsgBox (excessSpacesGone) End Sub function RemoveExcessSpaces (as the source string) string Dim result as string = source The result is = result.Replace ("", "C" result up to loop. Index ("") = 1 return result final function end class  

Comments