Forum Discussion

VaibsP's avatar
VaibsP
Copper Contributor
Feb 09, 2023
Solved

Search for the position of the last occurrence of a specific character in a text

I have to search for the position of the last occurrence of a specific character in a text.

For example, in the below text I want to know the position of the last occurrence of character "/"

abc.com/Computers/Laptops/INDT123L34

Which formulas can be used to accomplish this?

  • VaibsP Here are 2 options:

    using Excel365:

    =LEN(TEXTBEFORE(A1,"/",-1))+1

    older version:

    =LEN(A1)-LEN(TRIM(MID(SUBSTITUTE(A1,"/",REPT(" ",LEN(A1))),(LEN(A1)-LEN(SUBSTITUTE(A1,"/","")))*LEN(A1),LEN(A1))))

     

     

     

  • mtarler's avatar
    mtarler
    Silver Contributor

    VaibsP Here are 2 options:

    using Excel365:

    =LEN(TEXTBEFORE(A1,"/",-1))+1

    older version:

    =LEN(A1)-LEN(TRIM(MID(SUBSTITUTE(A1,"/",REPT(" ",LEN(A1))),(LEN(A1)-LEN(SUBSTITUTE(A1,"/","")))*LEN(A1),LEN(A1))))

     

     

     

Resources