Extracting string

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John

    #1

    Extracting string

    Hi

    I have a string with two $ sign in between, like ab$cdefg$eurur. I need to
    extract the right most part of the string from just right of the $ sign. How
    do I do this?

    Thanks

    Regards


  • Tiago Salgado

    #2
    Re: Extracting string

    Try this:

    Dim str As String = "ab$cdefg$eurur "
    str = str.Substring(0 , str.IndexOf("$" , 0))

    On Mon, 10 Jul 2006 19:16:53 +0100, John <John@nospam.in fovis.co.ukwrot e:
    Hi
    >
    I have a string with two $ sign in between, like ab$cdefg$eurur. I need
    to
    extract the right most part of the string from just right of the $ sign.
    How
    do I do this?
    >
    Thanks
    >
    Regards
    >
    >


    --
    Tiago Salgado

    Comment

    • Samuel Shulman

      #3
      Re: Extracting string

      You may use the Split Method that will split the string based on the
      character passed (in this case $)
      It returns an array of string and you may choose the string that you like
      (The string to the right of the right $ will have index 2 of the array)

      hth,
      Samuel Shulman




      "John" <John@nospam.in fovis.co.ukwrot e in message
      news:%238SuF0Ep GHA.1140@TK2MSF TNGP05.phx.gbl. ..
      Hi
      >
      I have a string with two $ sign in between, like ab$cdefg$eurur. I need to
      extract the right most part of the string from just right of the $ sign.
      How do I do this?
      >
      Thanks
      >
      Regards
      >

      Comment

      • Oenone

        #4
        Re: Extracting string

        John wrote:
        I have a string with two $ sign in between, like ab$cdefg$eurur. I
        need to extract the right most part of the string from just right of
        the $ sign. How do I do this?
        \\\

        Dim s1 As String = "ab$cdefg$eurur "
        Dim s2 As String

        s2 = Mid(s1, InStrRev(s1, "$") + 1)
        ///

        --

        (O)enone


        Comment

        • Travis Sharpe

          #5
          Re: Extracting string

          Oenone wrote:
          John wrote:
          >I have a string with two $ sign in between, like ab$cdefg$eurur. I
          >need to extract the right most part of the string from just right of
          >the $ sign. How do I do this?
          >
          \\\
          >
          Dim s1 As String = "ab$cdefg$eurur "
          Dim s2 As String
          >
          s2 = Mid(s1, InStrRev(s1, "$") + 1)
          ///
          >
          Dim s1 As String = "ab$cdefg$eurur "
          Dim temp() as string = s1.split("$")
          Dim result as string = temp(2)

          Comment

          • Dennis

            #6
            RE: Extracting string

            This will get the characters(euru r) after the last $ or return all if there
            are no $'s.

            Dim str As String = "ab$cdefg$eurur "
            str = str.Substring(s tr.LastIndexOf( "$")+1)


            --
            Dennis in Houston


            "John" wrote:
            Hi
            >
            I have a string with two $ sign in between, like ab$cdefg$eurur. I need to
            extract the right most part of the string from just right of the $ sign. How
            do I do this?
            >
            Thanks
            >
            Regards
            >
            >
            >

            Comment

            • Branco Medeiros

              #7
              Re: Extracting string

              John wrote:
              I have a string with two $ sign in between, like ab$cdefg$eurur. I need to
              extract the right most part of the string from just right of the $ sign. How
              do I do this?
              Besides all the other suggestions, you may have also:

              Dim S1 As String = "ab$cdefg$eurur "
              Dim S2 As String = S1.Substring(S1 .LastIndexOf("$ "c) + 1)

              Regards,

              Branco.

              Comment

              • Larry Lard

                #8
                Re: Extracting string


                John wrote:
                Hi
                >
                I have a string with two $ sign in between, like ab$cdefg$eurur. I need to
                extract the right most part of the string from just right of the $ sign. How
                do I do this?
                Lots of answers, and it's great to see that no one offered a regex!
                Perhaps our efforts here in the newsgroups are not all in vain...

                --
                Larry Lard
                Replies to group please
                When starting a new topic, please mention which version of VB/C# you
                are using

                Comment

                Working...