Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: Stripping Text

  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Location
    Brisbane, Australia
    Posts
    181
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Stripping Text

    I have a string of text:

    The string reads:

    content/about.txt

    how do i get rid of the "content/" part and the ".txt" part without effecting the "about" part

    -Thanks

  • #2
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    do you want to replace "content/about.txt" with "about" ?
    if you want to select the text between / and . you can do this with the followin code (VB script):

    dim positionslash, positiondot, string, resultlenght, begin, result 'string is your original string

    positionslash = InStr(string,"/")
    begin = positionslash + 1
    positionpoint = InStr(string,".")
    resultlenght = positionpoint - positionslash - 1
    result = Mid(string,begin,resultlenght)


    their might be a shorter way. anyone ?

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Not really - you could combine all that stuff into one line probably, but without doing that, matching it against a regular expression or using Split() would probably be about the same amount of code give or take a few bytes...
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)


  •  

    Posting Permissions

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