Find next non-whitespace character in VB.Net string array
Posted on 2006-11-24
In my VB.Net project I read in an entire text file and split the lines of the file into an array using split(FileContents, environment.newline())
I now have to iterate through the lines array searching for keywords. Finding the keywords is easy (using IndexOf) but following each key word I need to read unknown strings that could be located on the same line as the keyword (separated from the keyword by spaces, tabs, etc) or on subsquent lines (possibly preceeded by tabs, spaces, etc.)
Here are some examples, all of which are legal syntax for my keyword/parameter sets:
Keyword (tab) (tab) Parameter
Keyword (space) (space) (space) Parameter
Since I never know what the parameter string is going to be, I can't use IndexOf() to find them. What I need to be able to do is find the next non-whitespace character following the keyword and then read characters until the next whitespace character and consider everything in-between to be the Parameter string.
So, what's the easiest way of doing this? I suspect there's a way to do it using regular expressions, but I have never used them before in .Net and I'm having a hard time finding examples online that do what I'm trying to do here.
Many, many thanks!