Assuming the 3 letters are capital, adapt the following example:
using System;
using System.Text.RegularExpressions;
public class Program
{
public static void Main()
{
string input = "PSN1234";
Regex regex = new Regex("^(?!PAN)(?!SOS)[A-Z]{3}\\d{4}$");
if (regex.IsMatch(input))
{
Console.WriteLine("Valid");
}
else
{
Console.WriteLine("Not valid!");
}
}
}
If you want the letters to be case-insensitive, then change the [A-Z] to [A-Za-z]
+++++++++++++++++++++++++++++++++++++++++++++
This is in response to your added request:
The main part of your question - how to validate, is provided above, you have to do the rest,it is very straight forward and basic, adding a button to the form, creating a button click event, putting the validation routine in the button click event handler, and showing of a messgebox etc. Refer the following links:
1.
C# Button[
^]
2.
MessgeBox[
^]