Click here to Skip to main content
Rate this: bad
good
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 22:33pm
Edited 24-Dec-12 22: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
0 OriginalGriff 298
1 Sergey Alexandrovich Kryukov 181
2 Yogesh Kumar Tyagi 165
3 ChauhanAjay 156
4 Richard Deeming 150
0 Sergey Alexandrovich Kryukov 6,218
1 OriginalGriff 5,413
2 CPallini 2,473
3 Richard MacCutchan 1,627
4 Abhinav S 1,530


Advertise | Privacy | Mobile
Web02 | 2.8.140814.1 | Last Updated 25 Dec 2012
Copyright © CodeProject, 1999-2014
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