Click here to Skip to main content
12,248,339 members (48,520 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# .NET
Hi Friends ,

I Have Small Problem ,

string sample1 = "AK12-13/000000029024";
            string Patten1 = "^\\[A-Za-z]{2}-\\d{2}/\\d{12}$";
            System.Text.RegularExpressions.Match match1 = System.Text.RegularExpressions.Regex.Match(sample1, Patten1, System.Text.RegularExpressions.RegexOptions.IgnoreCase);
            if (!match1.Success)
            {
                MessageBox.Show("Please enter a valid  Patten.", "TEST", MessageBoxButtons.OK, MessageBoxIcon.Warning);
 
                return;
            }

But its not working , Any one Plz to Help
Condisions:

• The first two digits have to be Alphabets “AK”
• Secondly, the 5th character has to be a “-”
• Thirdly, the 8th character has to be a “/”
• Finally the last 12 characters after the 8th place onwards have to be numeric.
Posted 24-Dec-12 23:33pm
Edited 24-Dec-12 23:35pm
v2

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Hi,

Try this as Patten1 variable:
string Patten1 = "^AK.{2}-.{2}/[0-9]{12}$";
Hope this helps.
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160426.1 | Last Updated 25 Dec 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100