Question: Check if input string entered by user is in format like IIPIII, where I is integer number, any one digit number can be used on place of I and P is a character. 
Example if input is 32P125 it is valid string else N23P33 is invalid.

I tried using `string.Length` or `string.IndexOf("P")` but how to validate other integer values?

Answer: 
I'm sure someone can offer a more succinct answer but pattern matching is the way to go.

```
using System.Text.RegularExpressions;

string test = "32P125";

// 2 integers followed by any upper cased letter, followed by 3 integers.
Regex regex = new Regex(@"\d{2}[A-Z]\d{3}", RegexOptions.ECMAScript); 
Match match = regex.Match(test);

if (match.Success)
{
    //// Valid string   
}
else
{
    //// Invalid string
}

```
I would encourage the usage of [`MaskedTextProvided`](https://learn.microsoft.com/en-us/dotnet/api/system.componentmodel.maskedtextprovider?view=netframework-4.7.2) over `Regex`.

Not only is this looking cleaner but it's also less error prone.

Sample code would look like the following:

```
    string Num = "12P123";

    MaskedTextProvider prov = new MaskedTextProvider("##P###");
    prov.Set(Num);

    var isValid = prov.MaskFull;

    if(isValid){

        string result = prov.ToDisplayString();     
        Console.WriteLine(result);
    }

```