If you are okay with it, this should work for both mentioned cases and potential http
.
If data is in A1
- formula in B1 would be:
=IF(LEFT(A1,4)="http",MID(A1, FIND("/", A1, FIND("/",A1, FIND("/", A1, FIND("//",A1)+1)+1)+1)+1,256),MID(A1, FIND("/", A1, FIND("/",A1, FIND("/", A1, FIND("/",A1)+1)+1)+1)+1,256))
And in C1
would be:
=LEFT(B1,FIND("/",B1)-1)
It produces a following result:
| A | B | C |
|--------------------------------------------------------------------- |--------------------------------- |---------- |
| https://stackoverflow.com/questions/51633071/excel-extract-function | 51633071/excel-extract-function | 51633071 |
| stackoverflow.com/questions/51633071/excel-extract-function | 51633071/excel-extract-function | 51633071 |