Resolved How to find an alphanumeric substring

mauede

Well-known member
Joined
Sep 1, 2021
Messages
103
Location
Northwood - UK
Programming Experience
Beginner
This is a trivial problem but I cannot get a solution.
I am trying to make my code recognize strings like the following:
"PTV1_3000", "ITV3_4000"
The sub-string should contain a root-like "PTV", "ITV", "CTV" followed by one or more integer numbers followed by "_".
I tried different flavors of the following expression:

C#:
string str = "ITV2_123";
            if(str.Contains("ITV[0-9]*$_"))
            {
                Console.WriteLine("String OK)");
            }
            else
            {
                Console.WriteLine("string KO");
            }
            Console.ReadKey();

Is it possible to find alphanumeric sub-strings in a string?
Thank you so much
 

Latest posts

Back
Top Bottom