有没有一种简单的方法来计算一个文本字符串在另一个文本字符串中的出现次数?
Is there a simple way to count occurences of one text string within another text string?
是否有使用 PowerQuery 的简单方法来计算一个文本字符串在另一个文本字符串中的出现次数?
例如,如果我有字符串,"The quick brown fox jumps over the lazy dog and the lazy dog doesn't notice," 我如何轻松确定单词 lazy 和 dog 出现了两次?
我知道我可以使用 Text.Contains
来确定 lazy 和 dog 是否出现在字符串中,但我不知道一个简单的方法来确定 多少次它们发生了。
您可以拆分文本,使用搜索词作为分隔符。列表项的个数减去1,就是出现的次数。
let
String = "The quick brown fox jumps over the lazy dog and the lazy dog doesn't notice,",
Count = List.Count(Text.Split(String,"dog"))-1
in
Count
是否有使用 PowerQuery 的简单方法来计算一个文本字符串在另一个文本字符串中的出现次数?
例如,如果我有字符串,"The quick brown fox jumps over the lazy dog and the lazy dog doesn't notice," 我如何轻松确定单词 lazy 和 dog 出现了两次?
我知道我可以使用 Text.Contains
来确定 lazy 和 dog 是否出现在字符串中,但我不知道一个简单的方法来确定 多少次它们发生了。
您可以拆分文本,使用搜索词作为分隔符。列表项的个数减去1,就是出现的次数。
let
String = "The quick brown fox jumps over the lazy dog and the lazy dog doesn't notice,",
Count = List.Count(Text.Split(String,"dog"))-1
in
Count