1 Reply Latest reply on Jul 5, 2016 6:00 PM by swaroop.gantela

    Counting number of characters

    Brian Perron

      I have a string variable, colors, that is in the following format:

       

      {Red, Blue}

      {Green, Blue, Red}

      {Blue, Red}

      {Green, Orange, Blue}

       

      What I want to do is count the number of commas in the variable, and then add one to get the number of items contained in the brackets.  My thinking is to use REGEX_EXTRACT, compute the length, and then add 1.   

       

      LEN(REGEXP_EXTRACT([colors], "[,]")) + 1

       

      Obviously this isn't correct, as it is returning only NULL values.  Any help would be greatly appreciated!