• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 387
  • Last Modified:

match a pattern in c# using regex

I want to check this pattern

start with atleast 2 digits and a hyphen
like number number, anychars [hyphen]..repeat to match below string

280DABC2BC-227D8A97-144822B5BB0-17F42


here is what i did
            string fieldValue = "280DABC2BC-227D8A97-144822B5BB0-17F42";
               string pattern = @"(\d*[-])";
                Regex r = new Regex(pattern, RegexOptions.IgnoreCase);
                Match m = r.Match(fieldValue);
                if (m.Success)
                {
                    console.writeline "match found";

                }
0
ajaypappan
Asked:
ajaypappan
  • 2
1 Solution
 
Dan CraciunIT ConsultantCommented:
If there's always going to be 4 groups, try this:
@"(\d{2}[A-Z0-9]*-){3}\d{2}[A-Z0-9]*$"

Open in new window


HTH,
Dan
0
 
Dan CraciunIT ConsultantCommented:
Please read the grading guide: http://support.experts-exchange.com/customer/portal/articles/481419

The short story: if you give a grade other than A, you are required to post an explanation on what was deficient about the solution.

Thank you.
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now