$name =~s/_/\s+/;
Well, that's a bit silly, isn't it? You should understand that "\s+" in the left (regex-match) side of the s/// operator is supposed to mean "match one or more of any kind of white space character". And the right (replacement string) side of the s/// operator is supposed to say exactly what should replace the match.
So the reason why "\s+" can't do what you meant as part of the replacement string is: it doesn't say exactly what sort of white space character(s) -- or how many -- should replace the matched string. The same concept applies to any character-class, quantifier or grouping symbol used in a regex match: there's no way they can have the same meaning as replacement strings -- rather than being meaningless, they are simply taken "literally".
In reply to Re: Regular Expression Help
by graff
in thread Regular Expression Help
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |