Parsing a string

Discussion in 'Programming' started by forumposters, Mar 28, 2007.

  1. #1
    I have many strings that look like this: word1_word2.
    I want a function that takes this string and returns word1
    And, I also want a function that returns word2

    I imagine there is a function like Findbefore(string," _")
    and Findafter(string,"_")

    But I know that is not right. What Coldfusion functions exist to do this?
     
    forumposters, Mar 28, 2007 IP
  2. cfStarlight

    cfStarlight Peon

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    A list function would work

    <cfset myString = "word1_word2">
    <cfoutput>
    returns word1 = #ListFirst(myString, "_")# <br>
    returns word2 = #ListGetAt(myString, 2, "_")# <br>
    </cfoutput>

    http://livedocs.adobe.com/coldfusion/6.1/htmldocs/functi13.htm
     
    cfStarlight, Mar 28, 2007 IP
  3. datropics

    datropics Peon

    Messages:
    309
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    0
    #3
    very good cfstarlight
     
    datropics, Mar 29, 2007 IP