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. General Programming
  3. C#
  4. Find a string in a string... Living hell.

Find a string in a string... Living hell.

Scheduled Pinned Locked Moved C#
question
4 Posts 4 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.
  • H Offline
    H Offline
    heelios
    wrote on last edited by
    #1

    Hi, How could i find a string in a string ? For exemple, lets say i have the string "Hello! (How are you) ?", How could i find the string in the parentheses ? Is there a function that would return the "How are you" ? If not, is there a way to find the position of the "(" and of the ")" ? Thanks :) Heel

    W 1 Reply Last reply
    0
    • H heelios

      Hi, How could i find a string in a string ? For exemple, lets say i have the string "Hello! (How are you) ?", How could i find the string in the parentheses ? Is there a function that would return the "How are you" ? If not, is there a way to find the position of the "(" and of the ")" ? Thanks :) Heel

      W Offline
      W Offline
      Wjousts
      wrote on last edited by
      #2

      Of the top of my head, if you are looking for a string that appears between brackets then this should work: string myString = "Hello (how are you)?"; int start = myString.IndexOf("(")+1; int end = myString.IndexOf(")"); string subString = myString.Substring(start,end-start); subString will contain "how are you" You might be able to do something with Regex as well, but I'm not real familar with that.

      R 1 Reply Last reply
      0
      • W Wjousts

        Of the top of my head, if you are looking for a string that appears between brackets then this should work: string myString = "Hello (how are you)?"; int start = myString.IndexOf("(")+1; int end = myString.IndexOf(")"); string subString = myString.Substring(start,end-start); subString will contain "how are you" You might be able to do something with Regex as well, but I'm not real familar with that.

        R Offline
        R Offline
        ravfingcoder
        wrote on last edited by
        #3

        that's pretty straight forward string parsing. living hell? no.

        F 1 Reply Last reply
        0
        • R ravfingcoder

          that's pretty straight forward string parsing. living hell? no.

          F Offline
          F Offline
          fadee
          wrote on last edited by
          #4

          hmm... have you heard of Regular Experession... do check them out.. they really can help you in finding patterns... while making Living Hell a 'bit' better place :) mE --------------------- A gasp of breath, A sudden death: The tale begun. A rustled page Passes an age: The tale is done.

          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