|
-
Nov 4th, 2007, 10:17 AM
#1
Thread Starter
Lively Member
Help with regular expression
Hi everyone.
I need help to build the string syntax for this particular type of regular expression:
-the string will be length between 4 and 17 chars
-the only chars-set admitted are: A-Z in Uppercase and Lowcase; numbers (0,1,2,3,...9); the dot "." and the underscore "_"
Is there anyone that could help me??
Thanks in advance
Best regards.
-
Nov 5th, 2007, 06:54 AM
#2
Re: Help with regular expression
What language are you using?
-
Nov 5th, 2007, 06:55 AM
#3
Re: Help with regular expression
-
Nov 5th, 2007, 06:06 PM
#4
Re: Help with regular expression
 Originally Posted by penagate
[a-zA-Z0-9\._]{4,17}
Quick explanation:
[...] signifies a grouping of characters or rules. Useful for times such as these.
a-z, A-Z, 0-9 indicate ranges of characters. Note that on the ASCII table, a and A are 32 characters apart, so a straight a-Z will include more than you actually want. 0-9, fairly self explanatory.
_ speaks for itself. \. on the other hand... the period (.) is a special character in RegEx, and the \ is the escape character. \. is saying "cancel out of the period's special meaning", so the end result is that the period is checked directly.
{4,17} pretty obvious... length specification. A single number defines a maximum value, e.g. {20} would allow anything up to length 20. {4,} will allow any length LONGER than 4.
-
Nov 10th, 2007, 04:41 PM
#5
Thread Starter
Lively Member
Re: Help with regular expression
thank you everyone for the suggests and explanations about it.
Best Regards!
-
Nov 10th, 2007, 05:14 PM
#6
Re: Help with regular expression
 Originally Posted by timeshifter
A single number defines a maximum value, e.g. {20} would allow anything up to length 20.
Actually, {20} means exactly twenty instances. {1,20} would match from one instance to twenty.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|