Prelude
I am trying to perform an operation which requires me to parse every individual word a particular file. The most straightforward way of doing this would be to load the text using the:
$content = Get-Content -Path .\<filename>
Then I will break every individual word into an individual line (this allows me to do a word count AND single word search very quickly). The problem is when I then use this line of code:
$content.split("\s+")
which should create a new line (split) on every (one or more) whitespace character. Unfortunately, my results look like this:
$content.split("\s+")
The SpeechSynthe
izer cla
provide
acce
to the functionality of a
peech
ynthe
i
engine that i
in
talled on the ho
t computer. In
talled
peech
ynthe
i
engine
But when I run
$content -split("\s+")
The results will come out correctly:
$content -split("\s+")
The
SpeechSynthesizer
class
provides
access
to
the
functionality
of
a
speech
synthesis
My question Using powershell V.4 I am having trouble understanding what the difference between performing the operation.
$content.split("\s+")
and
$content -split("\s+")
is. And why they are outputting different results.
Is that functionality just broken?
Is there some other difference that I am not aware of at play here?