View Single Post
Old 01-16-2013, 09:10 PM   PM User | #5
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,248
Thanks: 59
Thanked 3,999 Times in 3,968 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Quote:
Originally Posted by alykins View Post
I don't know all the BI rules of your validation, but this regex should work for you

^([a-z][A-Z]{0,1})+\d{1,8}
That's not correct, Alykins. Not really even close.

That reads:
-- no characters BEFORE what follows (good)
-- a lower case letter
-- FOLLOWED by an optional upper case letter (huh???)
-- that pattern (lower then optional upper) repeated 1 *OR MORE* times
-- followed by from 1 to 8 digits
-- any number of any kinds of characters AFTER the preceding.

So that expression would *ACCEPT*:
s11111111 (as expected)
cZ3xx@#$--+111BB (after the \d{1,8}, *ANYTHING* is allowed)
s33333333333333333333333333333333333333333333 (8 digits accepted, but with no limit on what follows them)
aBcDeFgHiJKlMn4 (lower upper repeated any number of times, 1 digit minimum okay)
zzzzzzzzz77777777 (lower [no optional upper] repeated)
and many others.

From what he posted, I think it should be:
^[a-zA-Z]\d{8,8}$

Which reads:
-- no characters BEFORE what follows
-- one letter, either upper or lower case
-- followed by exactly 8 digits
-- no characters AFTER the preceding.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote