Please note that if you do not need data validation, you can do without a regular expression:
var results = line.Split(new[] {"\r", "\n"}, StringSplitOptions.RemoveEmptyEntries) .Select(v => v.Split(new[] {" "}, StringSplitOptions.RemoveEmptyEntries).Skip(1)) .SelectMany(x => x); Console.WriteLine(string.Join(",",results));
If you need only those numbers when the data is numbers, you can use
var results2 = Regex.Matches(line, @"(?m)(?<!^[\p{Zs}\t]*)(?<=[\p{Zs}\t])-?[0-9]*\.?[0-9]+(?:[eE][-+]?[0-9]+)?") .Cast<Match>() .Select(m => m.Value);
See C # demo .
The regular expression -?[0-9]*\.?[0-9]+(?:[eE][-+]?[0-9]+)? float / integer number is explained here .
Template Details
(?m) is a multi-line modifier that makes ^ match the beginning of a line(?<!^[\p{Zs}\t]*) is a negative lookbehind that does not match if there is a beginning of a line followed by horizontal + + space characters after it is immediately to the left of the current location(?<=[\p{Zs}\t]) is a positive lookbehind that requires a horizontal space before-?[0-9]*\.?[0-9]+(?:[eE][-+]?[0-9]+)? - integer / floating point number:-? - optional - char[0-9]* - numbers 0+\.? - optional . char[0-9]+ - 1 + digits(?:[eE][-+]?[0-9]+)? - optional sequence:[eE] - a e or e char[-+]? - optional - or + char[0-9]+ - 1 + digits.
source share