Hello All ,
Kindly help me with one scenario please. I have a text "RESIDENTIAL_GARAGE{173}" but I need to get "RESIDENTIAL GARAGE" . Please help me with this . Thanks a lot!!!
Hello All ,
Kindly help me with one scenario please. I have a text "RESIDENTIAL_GARAGE{173}" but I need to get "RESIDENTIAL GARAGE" . Please help me with this . Thanks a lot!!!
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Vishal YelveRank #178 · 13.6K reputationPosted Oct 1, 2022, 3:36 AM EDT
using System; public class Test { public static void Main(string[] args) { string input = "RESIDENTIAL_GARAGE{173}"; int index = input.IndexOf("{"); if (index >= 0) input = input.Substring(0, index); Console.WriteLine (input); } }Uday DodiyaRank #239 · 10.3K reputationPosted Oct 1, 2022, 12:43 AM EDT
You can use substring, try following
string str = "RESIDENTIAL_GARAGE{173}"; string str1 = str.Substring(0,str.IndexOf("{")); Console.WriteLine(str1);Uttam KumarRank #1,076 · 1.8K reputationPosted Sep 30, 2022, 2:41 PM EDT
You can use regular expressions. Try the below code.
string str = Regex.Replace("RESIDENTIAL_GARAGE{173}", @"[^A-Z]+", " ").Trim(); Console.WriteLine(s2);