Search code examples
google-sheetsgoogle-sheets-formula

GoogleSheets - Count characters in cell


I have the following cells with emojis.

enter image description here

As you can see I would like to get the value of these emojis as numeric.

I tried using a regex: =len(regexreplace(A2,"[^\⭐️]",""))

However, I do not get the desired result.

Any suggestions what I am doing wrong? Find below the link to the example spreadsheet:

Link to the Example Spreadsheet

I appreciate your replies!


Solution

  • added formula to your sheet. Please test it out:

    =MAKEARRAY(COUNTA(A2:A),1,LAMBDA(r,c,LAMBDA(ax,IF(ax=0,"-",ax))(LEN(REGEXREPLACE(INDEX(A2:A,r),"[^⭐]",""))+ LEN(REGEXREPLACE(INDEX(A2:A,r),"[^💥½¾]",""))/2)))

    - enter image description here

    ALTERNATE FORMULA

    =BYROW(IFERROR(INDEX(SPLIT(REGEXREPLACE(A2:A, "(.)", "$1|"), "|"))),LAMBDA(ax,IF(ax="",,LAMBDA(zx,IF(zx=0,"-",zx))(COUNTIF(ax,"⭐")+COUNTIF(ax,"💥")+IF((COUNTIF(ax,"½")>0)+(COUNTIF(ax,"¾")>0),0.5,)))))

    -

    enter image description here