Reputation: 295
i want to get the last value after / in excel.
www.google.com/new/oldpage.php
www.google.com/new/hello/wright.html
www.facebook.com/face/newface/demo.php
from the above link i want to separate the pagename for eg. from 1 url output should be www.google.com/new/ 2nd www.google.com/new/hello/ and so i used RIGHT formula but we can define only static. pls. provide if any one has the solution.
Upvotes: 1
Views: 163
Reputation: 7170
If A1 is www.google.com/new/oldpage.php
, use this code to get www.google.com/new/
:
=LEFT( A1, FIND( "|", SUBSTITUTE( A1, "/", "|", LEN(A1)-LEN(SUBSTITUTE(A1,"/","")) ) ) )
Use this code to get oldpage.php
:
=RIGHT(A1,LEN(A1)-FIND("|",SUBSTITUTE(A1,"/","|",LEN(A1)-LEN(SUBSTITUTE(A1,"/","")))))
As you can see, you need to SUBSTITUTE
some chars before calling the FIND
method.
Depending on your regional options, you must change "," (comma) in the formula for ";" (semicolon).
Upvotes: 1
Reputation: 3272
Excel doesn't provide a formula for reverse string searches so the following must be used
=IF(ISERROR(FIND("/",A1)),A1,RIGHT(A1,LEN(A1)-FIND("~",SUBSTITUTE(A1,"/","~",LEN(A1)-LEN(SUBSTITUTE(A1,"/",""))))))
Upvotes: 0
Reputation: 6984
Use this formula,
=MID(A16,SEARCH("^^",SUBSTITUTE(A16,"/","^^",LEN(A16)-LEN(SUBSTITUTE(A16,"/",""))))+1,999)
Upvotes: 0