Forum Discussion

PushpakumarGna1's avatar
PushpakumarGna1
Qrew Assistant Captain
6 years ago

how to count the number of specific characters

Hi All,

Can you please help me with a function/code to count the number of specific characters in a string

I would like to find the number of semicolon (;) in the string  "hi;how;are;you;"

thanks
Pushpakumar

------------------------------
Pushpakumar Gnanadurai
------------------------------
  • This is a way to do it if there is some reasonable limit to the maximum number of semicolons

    var text value = [my field with semicolons])

    Count(
    Trim(Part($value,1,";"))<>"",
    Trim(Part($value,2,";"))<>"",
    Trim(Part($value,3,";"))<>"",
    Trim(Part($value,4,";"))<>"",
    Trim(Part($value,5,";"))<>"",
    Trim(Part($value,6,";"))<>"",
    Trim(Part($value,7,";"))<>"",
    Trim(Part($value,8,";"))<>"",
    Trim(Part($value,9,";"))<>"",
    Trim(Part($value,10,";"))<>"",
    Trim(Part($value,11,";"))<>"",
    Trim(Part($value,12,";"))<>"",
    Trim(Part($value,13,";"))<>"",
    Trim(Part($value,14,";"))<>"",
    Trim(Part($value,15,";"))<>"",
    Trim(Part($value,16,";"))<>"",
    Trim(Part($value,17,";"))<>"",
    Trim(Part($value,18,";"))<>"",
    Trim(Part($value,19,";"))<>"",
    Trim(Part($value,20,";"))<>"",
    Trim(Part($value,21,";"))<>"",
    Trim(Part($value,22,";"))<>"",
    Trim(Part($value,23,";"))<>"",
    Trim(Part($value,24,";"))<>"",
    Trim(Part($value,25,";"))<>"")

    ------------------------------
    Mark Shnier (YQC)
    Quick Base Solution Provider
    Your Quick Base Coach
    http://QuickBaseCoach.com
    markshnier2@gmail.com
    ------------------------------
  • This is a way to do it if there is some reasonable limit to the maximum number of semicolons

    var text value = [my field with semicolons])

    Count(
    Trim(Part($value,1,";"))<>"",
    Trim(Part($value,2,";"))<>"",
    Trim(Part($value,3,";"))<>"",
    Trim(Part($value,4,";"))<>"",
    Trim(Part($value,5,";"))<>"",
    Trim(Part($value,6,";"))<>"",
    Trim(Part($value,7,";"))<>"",
    Trim(Part($value,8,";"))<>"",
    Trim(Part($value,9,";"))<>"",
    Trim(Part($value,10,";"))<>"",
    Trim(Part($value,11,";"))<>"",
    Trim(Part($value,12,";"))<>"",
    Trim(Part($value,13,";"))<>"",
    Trim(Part($value,14,";"))<>"",
    Trim(Part($value,15,";"))<>"",
    Trim(Part($value,16,";"))<>"",
    Trim(Part($value,17,";"))<>"",
    Trim(Part($value,18,";"))<>"",
    Trim(Part($value,19,";"))<>"",
    Trim(Part($value,20,";"))<>"",
    Trim(Part($value,21,";"))<>"",
    Trim(Part($value,22,";"))<>"",
    Trim(Part($value,23,";"))<>"",
    Trim(Part($value,24,";"))<>"",
    Trim(Part($value,25,";"))<>"")

    ------------------------------
    Mark Shnier (YQC)
    Quick Base Solution Provider
    Your Quick Base Coach
    http://QuickBaseCoach.com
    markshnier2@gmail.com
    ------------------------------
    • PushpakumarGna1's avatar
      PushpakumarGna1
      Qrew Assistant Captain
      Hi Mark,

      Just want to let you know that I found a easy way and it is length(string) - length(searchandreplace(string,";",""))

      basically length("abcd") - length(searchandreplace("abcd","a","")) 

      Thanks
      Pushpakumar

      ------------------------------
      Pushpakumar Gnanadurai
      ------------------------------
      • MarkShnier__You's avatar
        MarkShnier__You
        Icon for Qrew Legend rankQrew Legend
        I like that solution.

        ------------------------------
        Mark Shnier (YQC)
        Quick Base Solution Provider
        Your Quick Base Coach
        http://QuickBaseCoach.com
        markshnier2@gmail.com
        ------------------------------
    • PushpakumarGna1's avatar
      PushpakumarGna1
      Qrew Assistant Captain
      Hi mark,

      Thanks a lot !

      ------------------------------
      Pushpakumar Gnanadurai
      ------------------------------