You can use substring to obtain the result you want and do not necessarily need to use RegEx for this scenario. Below code would give you the required string with or without extension depending on your scenario.
public static void Main(string[] args)
{
string s = "S18_Dbs1.pdf";
string result;
bool keepExtention = true;
if(keepExtention)
result = s.Substring(s.IndexOf('_') + 1);
else
result = s.Substring(s.IndexOf('_') + 1, s.IndexOf('.') - s.IndexOf('_') - 1);
Console.WriteLine(result);
}
If you really are interested in solving it through Regex only (again I do not see a need in this scenario and would not recommend it)
//this is the quivalent regex if you want to print the name with extension
var r = new Regex(@"(?<=_).*");
Console.WriteLine(r.Match(s));
//this is the quivalent regex if you want to print the name without extension
var r1 = new Regex(@"(?<=_).*(?=\.)");
Console.WriteLine(r1.Match(s));
The ?<= is called positive lookbehind which would help in skipping the _ from match
The .* is the the 'string' of chars after the underscore
The ?=\. is called positive lookahead which would help in matching until .
I would recommend you go through the documentation on regex before you start playing around with it and even before that you determine if your scenario can be solved without regex as it makes your code easy to understand by others besides other benefits.
sub stringbetween_and.IndexOfandSubstring.\w+\d+\.\w{3}extracted the file name completely also without FS19_An1I.pdf, I do not know how to resolve this issue