How do I extract text that lies between parentheses (round brackets)?

后端 未结 17 1992
鱼传尺愫
鱼传尺愫 2020-11-22 15:12

I have a string User name (sales) and I want to extract the text between the brackets, how would I do this?

I suspect sub-string but I can\'t work out

17条回答
  •  盖世英雄少女心
    2020-11-22 15:32

    I came across this while I was looking for a solution to a very similar implementation.

    Here is a snippet from my actual code. Starts substring from the first char (index 0).

     string separator = "\n";     //line terminator
    
     string output;
     string input= "HowAreYou?\nLets go there!";
    
     output = input.Substring(0, input.IndexOf(separator)); 
    

提交回复
热议问题