Click here to Skip to main content
16,021,169 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to validate a string containing 1character & next 11 nos, like R12036580479.
i want the regular expression for it.
Posted

Used it
[A-Z][0-9]{11}
 
Share this answer
 
Try this:

C#
string input = "R12036580479";

if(Regex.IsMatch(input, @"^[A-Z]\d{11}$"))
{
    Console.Write("It's a match");
}
 
Share this answer
 
v2
Comments
Prasad_Kulkarni 6-Jul-12 7:37am    
Yes. A 5!
Manas Bhardwaj 6-Jul-12 7:40am    
thx!
Study this site carefully, you will know how to write Regular Expresssion.
Regular Expression Tutorial[^]

best of luck.
 
Share this answer
 
Comments
Prasad_Kulkarni 6-Jul-12 7:36am    
Good reference Rajesh! +5
Raje_ 6-Jul-12 7:44am    
thank you sir.
Get appropriate regular expression as you require from following link:
Expressions[^]

Similar answer:
Regular expression to validate a string[^]
Restrict user[^]

And a CP Article by Rahul:
A Tiny Javascript Framework for Common Validation Scenarios.[^]
 
Share this answer
 
Comments
Manas Bhardwaj 6-Jul-12 7:31am    
Good ref +5!
Prasad_Kulkarni 6-Jul-12 7:36am    
Thank you Manas!
Try:
[A-Z][0-9]{11}

Get a copy of Expresso [^] - it's free, and it examines and generates Regular expressions.

[edit]Typo - removed "," from regex - OriginalGriff[/edit]
 
Share this answer
 
v2
Comments
Prasad_Kulkarni 6-Jul-12 7:25am    
To the point, My 5
Saugata84 6-Jul-12 7:28am    
thanx it worked..
OriginalGriff 6-Jul-12 8:05am    
You're welcome!
Manas Bhardwaj 6-Jul-12 7:31am    
Correct +5!
vangapally Naveen Kumar 6-Jul-12 7:37am    
My 5

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900