How can I get a string between two specified strings?

I want to get a string that is between &bb& and &cc& . I am a Ctrader programmer that use C# and I am not familiar with regex in C#.

My string is:


The Result must be: 7185987

>Solution :

you can use string.indexof to find index of two patterns. and string.substring to exteract string between two index…

        string s = "788885221&bb&7185987&cc&12054555";

        var result = s.Substring( s.IndexOf("&bb&")+4, s.IndexOf("&cc&")- s.IndexOf("&bb&")-4 );

result = "7185987"

Leave a Reply