Click here to Skip to main content
15,896,444 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,
I want to create a regular expression to search a pattern. My search pattern is 4 alphanumeric / 5 alphanumeric / 2 alphanumeric. like (AP11/0258A/12).

i am using this

const string Pattern = "^[a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9]/[a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9]/[a-zA-Z0-9][a-zA-Z0-9]$";

but no match found.

Input string can have space or other symbols also.


Thanks
Posted
Updated 1-Jul-14 2:29am
v2
Comments
DamithSL 14-Jun-14 3:56am    
what are the symbols? if there symbols are there in the input, is it valid?

1 solution

Maybe:
C#
const string EIDPattern = @"^(?<group1>[A-Za-z0-9]{4})(?:[/\s])(?<group2>[A-Za-z0-9]{5})(?:[/\s])(?<group3>[A-Za-z0-9]{2})$"


The
Input string can have space or other symbols also.

is not directly translatable to a valid regular expression statement, though.

You should have a look at Expresso[^].
Cheers.
 
Share this answer
 
v2
Comments
204.sharma 14-Jun-14 3:59am    
Thanks

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