【发布时间】:2013-01-22 12:49:29
【问题描述】:
我的目标是遍历字符串数据库并在每次出现每个子字符串时获取计数。换句话说,我需要从字符串中提取所有可能的单词组合。
例如,输入可能是"this is the first string"。
我想提取"this is"、"is the"、"the first"、"first string"、"this is the"、"is the first"、"the first string"、"this is the first"、"is the first string"。
我只需要从左到右,总是按顺序。
我不确定从哪里开始。我已经有了读取数据库并保存到列表中的代码,只需要知道如何根据空格字符提取所有可能的子字符串。
【问题讨论】:
-
在任何三个或更多单词的子串都必须包含两个单词的子串的前提下,只需要实际搜索包含两个单词的子串即可。
-
shure 组合“这是第一个字符串”不是允许的组合? ...无论如何,这看起来像一个递归算法
-
刚刚回答了一个类似的问题,但是只需要 exactly
n单词的短语,使用正则表达式,我很好奇是否有正则表达式可以解决这个问题。
标签: c# .net regex string substring