It is necessary to extract a certain part of the line. Example:

"FIO eq Ivan Ivanov" => "Ivan Ivanov" "Id eq 5" => "5" "FIO cs a" => "a" "Count eq 587" => "587" 

The substring must be retrieved starting from the second space (not inclusive). How can this be implemented? Can use any regular expressions?

    1 answer 1

    As an option:

     using System; using System.Linq; namespace Test { class Program { static void Main(string[] args) { var testString = "Count eq 587"; var result = String.Join(" ", testString.Split(' ').Skip(2)); //или var result = String.Join(" ", Regex.Split(testString, @"\s+").Skip(2)); } } } 

    Perhaps there are more optimal options, in this case, breaks the string into an array of substrings where the separator is a space (one or more, for the second option), skips the first 2 substrings and the remaining unites with the same space. True, the number of these gaps is lost, if there are more than 2x, for the second option.

    • Very elegant solution, thank you very much - user190794