Perl Monk, Perl Meditation | |
PerlMonks |
Re^3: Function for reading fileby AnomalousMonk (Archbishop) |
on Mar 29, 2020 at 01:42 UTC ( [id://11114764]=note: print w/replies, xml ) | Need Help?? |
... the word regex \W ... It's important to understand what you're dealing with. The \W (that's big-W) character class (see perlrecharclass) matches any character that is not a \w (little-w) character. The \w characters are sometimes called "word" characters, but IIRC they originate with the set of characters that are allowed in a C- or Perl-language identifier; that's why _ (underscore) is included, but - (hyphen), for instance, is not. So \W is better described as the anti-word regex! And I agree with davido's point here that if [A-Za-z\W] really does the trick for you, then [^_\d] is more clear, readable, maintainable, and IMHO preferable. Update: Made "identifier" into a Wikipedia link. Give a man a fish: <%-{-{-{-<
In Section
Seekers of Perl Wisdom
|
|