I am trying to create a page that will check user input against a value in database. This page will have a text box for user to enter serial #.
Serial # length is variable but last 3 digit is always number.
For examples:
W04051234-PAY001 in this example code is 1234-PAY
W05051234-PAT002 in this example code is 1234-PAT
A12056040-G001 in this example code is 6040-G
B11056080-SU001 in this example code is 6080-s
Which is the best approach to extract CODE from user input?
Any help will be appriciated.
Thank
TekinUse the Regular Expression class, RegExp with a regular expression that looks for:
4 digits (or is it 3?) followed by
dash
followed by 1 or letters
That expression is:
\d{4}\-[A-Za-z]+
Actually,
I would like to Trancate first 5 digits and last 3 digits.
For examples:
W04051234-PAY001 in this example code is 1234-PAY
If you are attempting to strip a specific group of characters, the String class has numerous useful methods. I encourage you to read about the String class in the .net docs. I think the SubString() and Length() methods will be useful.
0 comments:
Post a Comment