61 users online (1 members and 60 guests)  


  Results 1 to 2 of 2

Related

  1. add/remove data from one list to another    Forum: Javascript Forum
    Replies: 0
  2. Remove the new line character from the String    Forum: Javascript Forum
    Replies: 5
  3. How to Remove underline from hyperlink?    Forum: HTML Forum
    Replies: 0
  4. remove browser toolbars    Forum: HTML Forum
    Replies: 1
  1. #1
    blink's Avatar
    New User

    Status
    Offline
    Join Date
    Mar 2005
    Posts
    19

    How to remove unneeded portions from string?

    Hello,

    If I have a string: "Today is my first day of rest of my life" and I want to remove everything except from "rest" to "my", how do I go about it? I need it so that the text can be dynamic so I need the regular expression formula where I can give the beginning of portion to end of portion.'

    Thanks!

  2. #2
    ALL's Avatar
    Super Dooper Nerd

    Status
    Offline
    Join Date
    Feb 2005
    Location
    localhost
    Posts
    382

    Re: How to remove unneeded portions from string?

    no problem...

    Code:
    Sub CutString{ #example use: CutString("Hello to Everyone", "to", "Everyone");
    return substr($_[0], index($_[0], $_[1]), index($_[0], $_[2])-index($_[0], $_[1])+length($_[2]));
    }
    That should work, although i cannot test it. it may need an offset of +/-1 but i dont think it does. if it doesnt work i will try and "free hand" debug it, but it should work.

    -ALL



Tags for this Thread