using System.Text.RegularExpressions;
public static void Main()
string input = "For example: TM000013452S20548, PB000013452S3DVSF.";
var matches = Regex.Matches(input, @"(?:TM|PB)0{0,}(\d+)");
foreach(Match m in matches)
Console.WriteLine(int.Parse(m.Groups[1].Value));