Reputation: 31252
I want a regex for string with 6-12 characters long, start with number, followed by anything and end with non-alpabet and non-number. i have this, but this does not work. Any help here? examples are
123abc$$
, 2%fat?
, 4ever!@
^[0-9](?=.*)[^a-z0-9]{6,12}$
Upvotes: 0
Views: 92
Reputation: 780724
Don't use a lookahead, because it doesn't consume characters, it just requires the regular expression to be next to that. You also don't need 6-12 non-alphanumerics, that's only the last character.
^\d.{4,10}[^a-z\d]$
Upvotes: 4