Newbie with RegEx question
Randal L. Schwartz
merlyn at stonehenge.com
Sat Jun 2 16:12:52 CDT 2001
>>>>> "MarkyMoon" == MarkyMoon <markmoon at teleport.com> writes:
MarkyMoon> Now that things are starting to make a little more sense to me,
MarkyMoon> I've been going through the llama book (again) and I'm having a bit
MarkyMoon> of a problem understanding why
MarkyMoon> will match a null set "" (in addition to abc,abcabc, abcabcabc
By definition. zero or more times. zero is one of that. :)
MarkyMoon> and WHY would you WANT to define a pattern that has the
MarkyMoon> possiblility of matching nothing?
Why would you want to define a pattern that matches
/my hovercraft is full of eels/ ?
Or stated in a different way, why would you want to make an exception
to the rules, and if so, how would you except it? It'd be like
defining a programming language that could only make "sensible"
programs, and disallowed "$a = $a;". It's just not really practical
to have those exceptions.
By the way /^/ also matches a null string, but only if it occurs at
the beginning of the string. Similarly, /$/ also matches a null
string, but only if it occurs at the end of the target string. So be
careful when you start disallowing null string matches. :)
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn at stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
More information about the Pdx-pm-list