Answer the question
In order to leave comments, you need to log in
What regular expression to clear domains from a tree?
Hey!
How can a regular expression for clearing domains from a directory tree look like, leaving the protocol and domain?
I do a bulk Find \\ Replace
For example, you need to leave only https:://site.ru
orhttp://en.site.ru
https://site.ru
http://site.ru
http://site.xyz/bla
https://site.com/blabla/test
https://en.site.com/blabla/test
site.ru/blabla/test/test2
Answer the question
In order to leave comments, you need to log in
<script>
var s_ar=new Array (
"https://site.ru",
"http://site.ru",
"http://site.xyz/bla",
"https://site.com/blabla/test",
"https://en.site.com/blabla/test",
"site.ru/blabla/test/test2"
);
var x_ar=new Array ();
var i, l=s_ar.length;
var r="";
for (i=0; i<l; i++)
{
x_ar=s_ar [i].split(/\//);
if (s_ar [i].indexOf ("://")!=-1)
r+=x_ar [0]+"/"+x_ar [1]+"/"+x_ar [2]+"\n";
else
r+=x_ar [0]+"\n";
}
alert (r);
</script>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question