Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

match a pattern in c# using regex

Posted on 2014-03-10
3
Medium Priority
?
383 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 2000 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

636 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