【发布时间】:2015-10-01 13:28:22
【问题描述】:
前奏
我正在尝试执行一项操作,该操作需要我将每个单词解析为特定文件。最直接的方法是使用以下命令加载文本:
$content = Get-Content -Path .\<filename>
然后我会将每个单词分成单独的一行(这使我可以非常快速地进行字数统计和单个单词搜索)。问题是当我使用这行代码时:
$content.split("\s+")
应该在每个(一个或多个)空白字符上创建一个新行(拆分)。不幸的是,我的结果如下所示:
$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
但是当我运行时
$content -split("\s+")
结果会正确出来:
$content -split("\s+")
The
SpeechSynthesizer
class
provides
access
to
the
functionality
of
a
speech
synthesis
我的问题 使用 powershell V.4 我无法理解执行操作之间的区别。
$content.split("\s+")
和
$content -split("\s+")
是。以及为什么他们输出不同的结果。
这个功能刚刚坏了吗?
这里还有其他一些我不知道的区别吗?
【问题讨论】:
标签: regex parsing powershell-4.0