Solved

match a pattern in c# using regex

Posted on 2014-03-10
3
368 Views
Last Modified: 2014-03-30
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
Comment
Question by:ajaypappan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 35

Accepted Solution

by:
Dan Craciun earned 500 total points
ID: 39918057
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
 
LVL 35

Expert Comment

by:Dan Craciun
ID: 39918298
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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question