Click to See Complete Forum and Search --> : Need Help Parsing String to Remove Text


L8knight
September 20th, 2004, 06:34 AM
I am trying to write a script that loops through a list of directory paths stored in a text file and remove all the text on each line that preceeds the "\\"of the path.
I was thinking maybe split, but I thought there was some other way to tell vbscript to read from the right of something.
Any ideas? I only need to keep the information from "\\" and on, to the right (then store it in another output file).

Any help, tips are appreciated!

Thanks.

f1shrman
September 20th, 2004, 08:55 PM
As you are looping through the data, you can use a combination of Mid and Instr to parse out the data you want.


Dim strTestPath1
Dim iLen

strTestPath1 = "\\servername\sharename\test1"

' get the location of the first backslash
' and add two to this value - which will move
' the location in the string to the first character
' after the double backslashes
iLen = InStr( 1, strTestPath1, "\" ) + 2

' using Mid to display the string without the leading back slashes
msgbox Mid( strTestPath1, iLen, (len(strTestPath1) - iLen))

' get the first character after the next back slash
iLen = InStr( iLen, strTestPath1, "\" ) + 1

' using Mid to display the string without the leading back slash
msgbox Mid( strTestPath1, iLen, (len(strTestPath1) - iLen))

' get the first character after the next back slash
iLen = InStr( iLen, strTestPath1, "\" ) + 1

' using Mid to display the string without the leading back slash
msgbox Mid( strTestPath1, iLen, (len(strTestPath1) - iLen))


HTH