Bill wrote:
>
> I'm looping over a file ,and as I get each line I'm looking for a
> particualr name. I've tried use the split method, but each line
> contains whitespaces, and an un even number of white spaces, so the
> text item I'm looking for isn't always th esame element.
>
> Here is a sample of each line of text I I get
>
> devicetype1 address1 sn1 file1.txt cost1
> devicetype2 address2 sn2 file2.txt cost2
>
> The file I'm looking for has the .txt extension it, so how would I go
> about finding the location, and going backwards till the firs twhite
> space?? I use regular expressions to parse free-form strings:
===
' use array to mimic file input
input = Array( _
"devicetype1 address1 sn1 file1.txt cost1", _
"devicetype2 address2 sn2 file2.txt cost2" _
)
Set parser = New RegExp
parser.Pattern = "\S+\.txt\b"
parser.IgnoreCase = True
For Each line In input
For Each match In parser.Execute(line) ' there will only be 1 match
' process file name here
WScript.Echo match
Next
Next
===
--
Steve
America is the only country that went from barbarism to decadence
without civilization in between. -Oscar Wilde