"abc_d1.txt" should get 0 "abc_d1_2.txt" should get 2 "abc_d1_14.txt" should get 14 "abc_d12_x2_156.txt" should get 156
Can do this currently with regex
int Id;
string pattern = @"(?<=_)\d+(?=\.\w+)|(?<!_\d+)(?=\.\w+)";
Regex rg = new Regex(pattern);
var z = rg.Match(fullFileName).Value;
Id = z == "" ? 0 : Convert.ToInt32(z);
But how to do it without regex?