[thelist] Anal String Replace (ASP)

Peter Brunone (EasyListBox.com) peter at easylistbox.com
Thu Oct 14 16:11:55 CDT 2004


   Isn't that going to split the filename after "Abbrv"?

 From: "Michael Pack" michaelpack at wvdhhr.org

FileName = "Abbrv. State Names.htm"

intFirstDot = InStr(1, FileName, ".")

strFirstHalf = Mid(FileName, 1, CInt(intFirstDot) - 1)
strSecondHalf = Mid(FileName, CInt(intFirstDot) + 1)

NewFileName = strFirstHalf & strSecondHalf
NewFileName = replace(NewFileName," ","")

response.write(NewFileName)

seems to do the trick....

MP
>>> rob.smith at THERMON.com 10/14/2004 1:20:13 PM >>>

Anal as in strict,

I have a file name:
filename = "Abbrv. State Names.htm"

What I'd like to do is:
filename = replace(filename,".","")

However this yields:
Abbrv State Nameshtm... not good

o o
-------000--^--000-------

What I think I may have to do, but this is the LONG way around

filename = replace(filename,".","_")
filename = replace(filename,"_htm",".htm")
filename = replace(filename,"_cad",".cad")
filename = replace(filename,"_doc",".doc")
filename = replace(filename,"_xls",".xls")
filename = replace(filename,"_pdf",".pdf")

...and so on and so forth for every known file extension to restore the
file
name.

There has GOT to be a smarter way around this. Ideas,

Rob Smith


More information about the thelist mailing list