【发布时间】:2012-01-14 19:34:09
【问题描述】:
如何找到一种快速计算文本中每个单词之间的间距数的方法?
每个空格代表一个值,
例如:一个空格是字母'a',两个空格是字母'b',等等。
文本示例
文字:
hello all the world
hello 和 all 之间有一个空格 --> 'a', all 和 the 之间有两个空格 --> 'b', ...
单词 --> 'abc'
【问题讨论】:
-
text : "hello all the world" one space between hello and all --> 'a', two spaces between all and the --> 'b', ...- 我不明白那个例子的最后一部分。我只能在例句中的每个单词之间看到一个空格。 -
@birryree 如果你看源码,他似乎输入了“hello_all__the___world”,但编辑器并没有显示多余的空格。
-
@brc - 哦,我现在看到了 - JBernardo 编辑了它,我猜只有代码模式适用于多间距。