Solved

match a pattern in c# using regex

Posted on 2014-03-10
3
356 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
  • 2
3 Comments
 
LVL 34

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 34

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Login 17 50
2 questions 10 25
updating order of the rows, N+1 query issue, C#, asp.net, MVC, SQL Server 3 26
Need to start a web service from Visual Studio 2015 Pro 2 24
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

773 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