Search code examples
arraysregexgoogle-sheetsgoogle-sheets-formulaarray-formulas

How to split and find last index in Google Sheets?


I need to achieve something like following in Google-sheets:

tag_name    
A_B_C       C
A_B_C_D     D

I am using following formaula:

=INDEX(SPLIT(B2, "__"), 0, 3)

I want to dynamically pass last index of the set of values returned by split.


Solution

  • You can try REGEXEXTRACT formula, I am assuming your data range starts from "A1". Put this formula in "A1" and fill it down per your requirement

    =REGEXEXTRACT(A1,"\S$")
    

    enter image description here