Owen wrote:
I found a message from Randal Schwartz, Message-ID:
<[EMAIL PROTECTED]>#1/1
which gave a regular expression for a valid Unix name,


        /^(?=.*?\D)[a-z\d]+$/

That works but why does it work?

/
^ # Start of a string (?= # 0 or 1 instance of .*? # anything but a newline
\D # Non digit
) #

[a-z\d]+ # All match a-z and any digit at
$ # End of a string
/



I tried breaking it down like above but it still doesn't say "Must not be all numbers and letters must be all lowercase"

Any help in turning that re into plain words would be appreciated

(?=.*?\D) is a zero-width assertion so it doesn't affect the match which is /^[a-z\d]+$/ -- match a string whose only characters are a-z0-9. When you add the zero-width assertion it ensures that there is at least one \D character in the match.


John -- use Perl; program fulfillment

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to