Rj. Rj. - 8 months ago 53
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 (" ")?


You can use LINQ:

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