【问题标题】:Is there a simple way to count occurences of one text string within another text string?有没有一种简单的方法来计算一个文本字符串在另一个文本字符串中的出现次数?
【发布时间】:2017-05-30 17:07:03
【问题描述】:

有没有一种简单的方法,使用 PowerQuery 来计算一个文本字符串在另一个文本字符串中出现的次数?

例如,如果我有字符串“The quick brown fox jumps over the lazy dog and the lazy dog didn't notice”,我如何轻松确定lazy和dog这两个词出现了两次?

我知道我可以使用Text.Contains 来确定字符串中是否出现lazy 和dog,但我不知道一种简单的方法来确定它们出现了多少次

【问题讨论】:

    标签: powerquery m


    【解决方案1】:

    您可以使用搜索词作为分隔符来拆分文本。列表项的数量减 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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-10-27
      • 2011-07-13
      • 1970-01-01
      • 2011-07-01
      • 2014-11-14
      • 1970-01-01
      • 1970-01-01
      • 2014-05-26
      相关资源
      最近更新 更多