string
-
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
-
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
Use Regular Expressions, it will help you out.
-
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
Check this out this regular exp: @"(\([a-zA-Z]+\))|(\s?-\s?[a-zA-Z]*)" This might help u out.
-
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
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.