[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl-AnyPerl] Dates, times, and month names



Eric Albert wrote:
> 
> > Excerpt of reply (sent 28 March 1999) by Eric Albert:
> >> That's easily fixed by changing (?:\.\d+)? to (?:[\.:]\d+)?
> >
> >The unnecessary backslash in [.:] might confuse me.  The Camel (p. 64,
> >third item of rule 6) explains character classes and the special
> >meaning of '^', '-', '\', and ']'.  It then says:
> >:   Note that most other metacharacters lose their meta-ness inside
> >:   square brackets.
> 
> Hmph.  Thanks for pointing that out....  Then again, I tend to assume that
> '\' is needed to escape anything that normally requires escaping, so for
> me, dropping '\' might be confusing.  Of course, you could easily argue
> that I should just learn the intricacies of the language a bit better. :)
> 

Perl was specifically defined so that you can escape anything that
normally needs escaping, even in cases when it doesn't, and still
get intuitive results.  In other words, a backslash followed by a non-word
character always corresponds to the literal non-word character [*]:

  "\&\+" =~ /[\&\+]+/;



[*] Except in single-quoted strings, where \ is only special before \ and '.

Ronald

==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-anyperl-request@macperl.org