Results 1 to 3 of 3
Thread: Java newb Q: 8-digit id
- 09-28-2008, 07:20 PM #1
Member
- Join Date
- Sep 2008
- Posts
- 1
- Rep Power
- 0
- 09-28-2008, 10:49 PM #2
Member
- Join Date
- Jul 2008
- Posts
- 68
- Rep Power
- 0
Do some reading on Regular Expressions (Java Pattern and Matcher object APIs should help too.) Regular expressions are a very powerful addition to any developer's arsenal.
Assuming that your ID member is generated somehow you'll want to validate its content as a string against a Pattern to ensure it meets your criteria.
Example Pattern: $[1|2|9]{1}[0-9]{7}^ The pattern basically says a "match" starts with a single 1,2, or 9 digit character ($[1|2|9]{1}) and ends with 7 digits between 0 and 9 ([0-9]{7}^).
Note, this may not be exactly the patter you want to use; my regex-foo is a bit rusty.
Hope this points you in the right direction.Last edited by racerxadam; 09-28-2008 at 10:54 PM.
- 09-29-2008, 02:37 PM #3
Please explain. Are you asking for a number with 8 digits that starts with 1,2 or 9? What determines which digit it must start with?implement an 8-digit id ... must begin with 1,2 or 9
Random or next in line?
For example the first would be: 10000000, the next 100000001 etc. to 19999999 and then to 20000000
Doing them inline like above would keep them unique.
Similar Threads
-
Newb Topics
By dkizzy in forum New To JavaReplies: 2Last Post: 09-17-2008, 07:01 AM -
convert getValue result in a 4 digit number
By roseline43 in forum New To JavaReplies: 0Last Post: 09-02-2008, 08:44 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks