...

View Full Version : regex problem



zodehala
08-23-2009, 10:45 PM
does ^[a-zA-Z_]{3} match between a-z with 3 digit plus _

Fou-Lu
08-23-2009, 11:30 PM
No it matches any string starting with three characters a-zA-Z_. So aBc is valid, but ab2 is not and a_c222 is valid. If its only supposed to be 3 characters in length, you need to add a $ at the end of you're pattern to bound it between start and end.
Also, if you plan on adding digits to it, use the \w instead. A word is classified as any alphanumeric character plus the _.

zodehala
08-24-2009, 11:49 AM
No it matches any string starting with three characters a-zA-Z_. So aBc is valid, but ab2 is not and a_c222 is valid. If its only supposed to be 3 characters in length, you need to add a $ at the end of you're pattern to bound it between start and end.
Also, if you plan on adding digits to it, use the \w instead. A word is classified as any alphanumeric character plus the _.

how can i do it with 3 digit between a and z

Fou-Lu
08-24-2009, 12:34 PM
^[a-z]{3}$

zodehala
08-24-2009, 09:39 PM
and _



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum