I think this template meets the specification.
string pattern = @"^[VvEePpTt](?:$|-(?:$|\d{1,12}$))";
Console.WriteLine(Regex.IsMatch("V", pattern));
Console.WriteLine(Regex.IsMatch("v-", pattern));
Console.WriteLine(Regex.IsMatch("P-123", pattern));
Console.WriteLine(Regex.IsMatch("t-012345678901", pattern));
Console.WriteLine(Regex.IsMatch("t--", pattern));
Console.WriteLine(Regex.IsMatch("E-0123456789012", pattern));
Breakdown of the structure:
^ - start of string
[VvEePpTt] - any of the given characters, exactly once
(?: - start a non-capturing group...
$|- - ...that matches either the end of the string or exactly one hyphen
(?: - start a new non-capturing group...
$|\d{1,12}$ - that matches either the end of the string or 1 to 12 decimal digits
)) - end the groups
source
share