SOLVED

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

Copper Contributor

# 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?

2 Replies
best response confirmed by mtarler (Silver Contributor)
Solution

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

@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))))``

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

@mtarler Thanks for the quick response. Its working.

1 best response

Accepted Solutions
best response confirmed by mtarler (Silver Contributor)
Solution

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

@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))))``