Extracting text between two instances of a character

Occasional Contributor

I have a URL strings in cells in a column. In another sell I'd like to extract a portion of the URL string.

This is the string in A2.


The URL's always have the same format. I want to extract the last digits between the last two slashes, that is /1452258783/ so that cell B2 contains 1452258783.

I was elaborating with LEFT, RIGHT, MID and LEN functions but couldn't get it right. It would be interesting to have two formulas. One extracting text between the last two slashes couting the slashes from the left (5:th slash from the left) and another forumla counting the slahses from the right (between first and second slash).

Does someone have any suggestions how to solve this?

6 Replies

@Peter Johansson 

If you have exactly the same format, i.e. same number of slashes and https:// at the left, that could be



best response confirmed by Peter Johansson (Occasional Contributor)

@Peter Johansson 

More universal




@Sergei Baklan 


Thank you for the great answers. The first longer formula works for me. The second outputs:


And not the number between the last two slashes.


What if the number of digits in between the last two slashes are fluctuating? It seems the formula is fixed in that sense. EDIT: I was wrong. I checked the wrong cell. It seems to work as expected.

@Peter Johansson 


Peter, perhaps I misunderstood you with the second requirement. Anyway, first formula in second post shall return number independently of how many slashes you have, it only assumes URL starts from http:// or https://. But that also could be ignored, just the formula will be bit longer.

@Peter Johansson 

If it is a consisting pattern you could try Flash Fill.


@Sergei Baklan This is excellent thank you.