Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. find value after space in string

find value after space in string

Scheduled Pinned Locked Moved ASP.NET
helptutorial
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    playout
    wrote on last edited by
    #1

    Hi, I get a string say "07915 25D3". The problem is, the value before the space can be anything from 1 - 12 in length, and the value after the space anything from 2 - 12 characters. I just need to get the value after the space, "25D3", in the string. I am not sure how to do this.

    M N 2 Replies Last reply
    0
    • P playout

      Hi, I get a string say "07915 25D3". The problem is, the value before the space can be anything from 1 - 12 in length, and the value after the space anything from 2 - 12 characters. I just need to get the value after the space, "25D3", in the string. I am not sure how to do this.

      M Offline
      M Offline
      Martin J Evans
      wrote on last edited by
      #2

      Hi assuming the character is always a space you could use the split() function: ---------------------------------------------------------- Dim _str As String = "07915 25D3" dim _s as string = str.Split(" ")(1).ToString ---------------------------------------------------------- In this instance _s will give you the value 25D3. The argument passed into the split function is a character or number of characters are used to break down the string into an array. The value of _s is evaluated to the 2nd element of the array (25D3) Hope this helps:) MJ

      P 1 Reply Last reply
      0
      • M Martin J Evans

        Hi assuming the character is always a space you could use the split() function: ---------------------------------------------------------- Dim _str As String = "07915 25D3" dim _s as string = str.Split(" ")(1).ToString ---------------------------------------------------------- In this instance _s will give you the value 25D3. The argument passed into the split function is a character or number of characters are used to break down the string into an array. The value of _s is evaluated to the 2nd element of the array (25D3) Hope this helps:) MJ

        P Offline
        P Offline
        playout
        wrote on last edited by
        #3

        Thanks MJ, It worked perfectly!! Just what I wanted.

        1 Reply Last reply
        0
        • P playout

          Hi, I get a string say "07915 25D3". The problem is, the value before the space can be anything from 1 - 12 in length, and the value after the space anything from 2 - 12 characters. I just need to get the value after the space, "25D3", in the string. I am not sure how to do this.

          N Offline
          N Offline
          Neeraj Arora
          wrote on last edited by
          #4

          There is one another way to do it. suppose your string is stored in variable 'strCustId'. String strRightText = strCustID.Substring(strCustID.IndexOf(" "));

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups