Re: Extract information from text file

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



"James Whitlow" wrote in message
news:ek5T%237ujFHA.3148@xxxxxxxxxxxxxxxxxxxxxxx
: "Roland Hall" <nobody@nowhere> wrote in message
: news:OOUjkuujFHA.3656@xxxxxxxxxxxxxxxxxxxxxxx
: > "James Whitlow" wrote in message
: > news:%23UZhd9sjFHA.3300@xxxxxxxxxxxxxxxxxxxxxxx
: > : Use could also use the 'Scripting.FileSystemObject' to do the work for
: > you:
: > :
: > : Dim FSO
: > : Set FSO = CreateObject("Scripting.FileSystemObject")
: > : path = "C:\mydir\mysubdir\myfile.ext"
: > : MsgBox FSO.GetFileName(path)
: >
: > Hi James...
: >
: > If he was getting the file information via FSO, this would be the best
way
: > but he's getting it from a text file he's parsing.
:
: The filename being parsed does not have to be a real file. Copy the above
: into a *.vbs file and execute it. It works just fine on my XP Pro
computer.

I know it does. But I didn't see a need to create an object.

: But, if you don't want to use FSO, you can use:
:
: path = "C:\mydir\mysubdir\myfile.ext"
: path = Mid(path, InStrRev(path, "\") + 1)
: MsgBox path
:
: Or you can also use a regular expression:
:
: Dim RegEx
: Set RegEx = New RegExp
: RegEx.Pattern = ".*\\"
: path = "C:\mydir\mysubdir\myfile.ext"
: path = RegEx.Replace(path, "")
: MsgBox path

Those are good examples. There are quite a few ways.

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp


.



Relevant Pages