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. string

string

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

    Hi, I have texts such as the following... "EUR50,000 (Wholesale)" or "USD 1,000 - Retail" ... ... ... How do I just pull out the text i.e. (Wholesale) or Retail ? I am using this at present and it seems to work if there is brackets around but not if there is "-" _strRetailWholeSale = strValues.Substring(intPos, strValues.Length - intPos).Trim() Thanks

    S M 3 Replies Last reply
    0
    • A arkiboys

      Hi, I have texts such as the following... "EUR50,000 (Wholesale)" or "USD 1,000 - Retail" ... ... ... How do I just pull out the text i.e. (Wholesale) or Retail ? I am using this at present and it seems to work if there is brackets around but not if there is "-" _strRetailWholeSale = strValues.Substring(intPos, strValues.Length - intPos).Trim() Thanks

      S Offline
      S Offline
      Sunil Lanke
      wrote on last edited by
      #2

      Use Regular Expressions, it will help you out.

      1 Reply Last reply
      0
      • A arkiboys

        Hi, I have texts such as the following... "EUR50,000 (Wholesale)" or "USD 1,000 - Retail" ... ... ... How do I just pull out the text i.e. (Wholesale) or Retail ? I am using this at present and it seems to work if there is brackets around but not if there is "-" _strRetailWholeSale = strValues.Substring(intPos, strValues.Length - intPos).Trim() Thanks

        S Offline
        S Offline
        Sunil Lanke
        wrote on last edited by
        #3

        Check this out this regular exp: @"(\([a-zA-Z]+\))|(\s?-\s?[a-zA-Z]*)" This might help u out.

        1 Reply Last reply
        0
        • A arkiboys

          Hi, I have texts such as the following... "EUR50,000 (Wholesale)" or "USD 1,000 - Retail" ... ... ... How do I just pull out the text i.e. (Wholesale) or Retail ? I am using this at present and it seems to work if there is brackets around but not if there is "-" _strRetailWholeSale = strValues.Substring(intPos, strValues.Length - intPos).Trim() Thanks

          M Offline
          M Offline
          musefan
          wrote on last edited by
          #4

          well if your two examples are the only types it could be i would split the string with spaces, then get the last string in the resulting array. Then you just need to remove brackets if need be. Something like... string[] results = inputString.Split(' ')' string result = result[result.Length-1].Replace("(", "").Replace(")", "");

          Life goes very fast. Tomorrow, today is already yesterday.

          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