Rj. Rj. - 4 years ago 207
C# Question

How to get a string between 2 specific characters in C#

Having a hard time with Regex.

I have this string:

I need to replace this whole number "11.000000" with another number.

How do I identify this string by saying:

Give me the string right before "%" until you reach the first blank space (" ")?

Answer Source

You can use LINQ:

var myString = "Fixed Breakeven with 11.0000000% Fees";
var number = myString.Split('%').First().Split(' ').Last();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download