string manipulation

Results 1 to 2 of 2

Thread: string manipulation

  1. #1
    mamta Guest

    Default string manipulation

    How can i extract a portion of file path just to get the filename?<BR><BR>For eg http://myfolder/specificfolder/myfile.gif<BR><BR>How do i extract only myfile.gif?Is using the Mid function the best option

  2. #2
    Join Date
    Dec 1969

    Default RE: string manipulation

    &#062;http://myfolder/specificfolder/myfile.gif<BR>&#062;How do i extract only myfile.gif?<BR><BR>Several ways. Fastest is probably:<BR><BR>&#060;%<BR>str = "http://myfolder/specificfolder/myfile.gif"<BR>filenameonly = Mid( str, InStrRev( str, "/" )+1 )<BR>%&#062;<BR><BR>InStrRev starts at the end of the string and looks backwards for the given character. We add back one to get past it and then Mid gives us everything from that point on.<BR><BR>ANOTHER WAY:<BR><BR>&#060;%<BR>str = "http://myfolder/specificfolder/myfile.gif"<BR>temp = Split( str, "/" )<BR>filenameonly = temp( UBound(temp) )<BR>%&#062;<BR><BR>Kind of hokey, but works. Splits the original string apart into pieces separated by / characters. Then gets the last piece by getting top element of the array.<BR><BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts