How to extract particular string from given URL

Posted by Vishalneeraj-24503 under JavaScript on 12/20/2017 | Points: 10 | Views : 2289 | Status : [Member] [MVP] | Replies : 0
Hello Guys,

I came around a situation where i have to extract a particular string on a given URLs/Sites :-

suppose URL is :-
www.yahoo.com/sites/spec/aaa/aaa.aspx
https://facebook.com/sites/test/bbb/test.aspx
uat-abc-link/project/sites/fastplay/kwott/site-page/dbs.html
https://amst-tpage/speg/minaral-water/pages/mpower.aspx
www.marklet/mplay/extra.fff/chart.aspx


Now my concern is - I want to get URL till spec/test/speg/fastplay/mplay and remove everything after that words.

So my output would be :-
www.yahoo.com/sites/spec
https://facebook.com/sites/test
uat-abc-link/project/sites/fastplay
https://amst-tpage/speg
www.marklet/mplay.



Please note that - Not every URLs/ Sites have .com domain.

Thanks in advance....




Responses

(No response found.)

Login to post response