SPONSORS:






User Tag List

Results 1 to 7 of 7

Thread: Striping Text

  1. #1
    Senior Member
    Join Date
    Jul 2001
    Posts
    147
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Striping Text

    G'Day All...

    How's it going?

    I just have a quick question. I have a string as follows:

    "text 1/text 2/text 3"

    Is there a way that I can strip this string so that I can get text 3.

    The string will be set in this format with "/", however, it could be anywhere from text 1 to text 7

    EG: text 1/text 2/text 3/text 4/text 5/text 6/text 7

    In the example above I would need to get "text 7" and ignore all other text before the last "/".

    If this helps I am testing on a windows application.

    ------------------
    Who Tests The Tester...
    Who Tests The Tester...

  2. #2
    Senior Member
    Join Date
    Jul 2001
    Location
    Elizabeth, CO, USA
    Posts
    653
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Striping Text

    The GetField function would help (partially) in stripping out the text. However, you'll also need something to count the number of instances of the delimiter so that you know which field to get.

    Something like this:

    You can then use that function along with GetField to get just the last item out of it. For example:

    Hope this helps.

    ****- Dave

    ------------------
    Amelior Technology
    dreed@ameliortech.com

    [This message has been edited by dcreed (edited 08-21-2001).]
    WaltzingRhino.com
    A concerned Borland customer, a fly in the ointment, a wrench in the works.

  3. #3
    Senior Member
    Join Date
    Jul 2001
    Posts
    147
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Striping Text

    Thanks Dave it works perfectly...

    ------------------
    Who Tests The Tester...
    Who Tests The Tester...

  4. #4
    Senior Member
    Join Date
    Jun 1999
    Location
    Fremont, CA, USA
    Posts
    355
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Striping Text

    The function you want is comon in other launguages as "split". Years ago I wrote a split() function in 4Test. I still use is constantly.


    The return value will have the number of items and theList will be your list.

    So, if you wanted the last item in an array




    ------------------
    David Genrich
    david@e2Open.com

  5. #5
    Senior Member
    Join Date
    Jun 2000
    Location
    Sunyyvale CA USA
    Posts
    422
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Striping Text

    Try using GetString with the delimeter as space and /.

    ------------------
    Sree
    Sree

  6. #6
    Senior Member
    Join Date
    Nov 2000
    Location
    Bloomington, IL
    Posts
    142
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Striping Text

    If you want to use StrPos and only find the last instance of a common delimiter try adding the option parameter bBackward. This will search for the last instance of the delimiter.

    Then use the Length and Right functions to
    get the last value.
    sString = "val1/val2/val3"

    iPos = StrPos (sString, "/" , TRUE)

    iLen = Len (sString)
    sSub = Right (sString, iLen - (iPos - 1))

    Mike


    ------------------

  7. #7
    Member
    Join Date
    Jan 2001
    Location
    Westborough, mA, USa
    Posts
    91
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Striping Text

    Try

    sLastString = SubStr(sStr,StrPos(sStr,"/",True))

    where sStr = "text 1/text 2/text 3"

    p.s: This works only if u want the last text ie "text3"

    ------------------

 

 

Posting Permissions

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

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.0.9 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Questions / Answers Form provided by vBAnswers (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominatevBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 09:11 PM.

Copyright BetaSoft Inc.