Rj. Rj. - 1 month ago 16
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

You can use LINQ:

var myString = "Fixed Breakeven with 11.0000000% Fees";
var number = myString.Split('%').First().Split(' ').Last();