So, would this be it for the optional?

/^[a-zA-Z0-9][\w-]*\.[a-zA-z]+$/

thanks

> --On Friday, October 10, 2003 17:45 -0700 "[EMAIL PROTECTED]"
> <[EMAIL PROTECTED]> wrote:
>
>> start with [a-zA-Z0-9]
>> chars following is [\w-] BUT IS OPTIONAL
>>
>> /^[a-zA-Z0-9][\w-]\.[a-zA-z]+$/
>>
>> I think the regex is not doing the option \w part.
>
> Correct, it isn't.  You haven't asked it to...  To make it optional
> you need to follow the [\w-] with a count which says it is optional.
> The count would be in this form: {$min,$max}, where $min and $max are
> the minimum and maximum counts, respectively.  You can leave out $max
> if there is no maximum count.  (But you still need the comma; without
> it you have an _exact_ count.)  So for zero or more times you need
> the quantifier: {0,}.
>
> There are also three shortcut quantifiers: '*', '+', '?'.  (Without
> the quotes.)  Their meanings are:
> * = {0,}
> + = {1,}
> ? = {0,1}
>
> Note that all the quantifiers are 'greedy'[1]: they match the longest
> string of characters they possibly can.
>
> Ok, now that we've got that over with, why aren't you using the
> 'validate' sub?  It is likely to be faster than the above regrex...
>
> Daniel T. Staal
>
> [1] Well, there is a way around this.  But that's another lesson.
>
> ---------------------------------------------------------------
> This email copyright the author.  Unless otherwise noted, you
> are expressly allowed to retransmit, quote, or otherwise use
> the contents for non-commercial purposes.  This copyright will
> expire 5 years after the author's death, or in 30 years,
> whichever is longer, unless such a period is in excess of
> local copyright law.
> ---------------------------------------------------------------
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



-----------------------------------------
eMail solutions by 
http://www.swanmail.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to