Regular Expression Help

  • Thread starter Thread starter Jami
  • Start date Start date
J

Jami

How i can define regular expression for following cases

A100123456, 1B00345787

1- here i want first two charcters as alphanumeric
2- next two characters must be 00 (zero)(zero)
3- next six characters must be numeric 0-9

what will be the regular expression for the above

Regards,

Jami
 
Jami said:
How i can define regular expression for following cases

A100123456, 1B00345787

1- here i want first two charcters as alphanumeric
2- next two characters must be 00 (zero)(zero)
3- next six characters must be numeric 0-9

what will be the regular expression for the above

@"[A-Z0-9]{2}00[0-9]{6}"
should give you an idea. The "[A-Z0-9]" might need to be adapted
depending on what exactly you regard as alphanumeric characters and
whether you also want to allow lower case letters.
And if you want to test that a string contains nothing but a string
matching above expression then you should add "^" at the beginning and
"$" at the end:
@"^[A-Z0-9]{2}00[0-9]{6}$"
 
Back
Top