Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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:

"788885221&bb&7185987&cc&12054555"

The Result must be: 7185987

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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"

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading