我想用<常规词语分拨一个插座,但我已经遇到一些问题。 我有这样的说明:
$text=" one two three";
Then I try to split it into alphabetic words:
#@words=split(" ", $text); #1 this works
@words=split("[^a-zA-Z]", $text); #2 this doesn t work
for $word (@words){
printf "word: |$word|
";
}
So the commented method(1) works fine. As expected I get printed:
word: |one|
word: |two|
word: |three|
However with the second method(2) I get this:
word: ||
word: |one|
word: |two|
word: |three|
So although logically the second method should be equivalent to the first one, in practice it doesn t behave the same way. Why is that?