I have a url like e.g.:
http://www.intereconomia.com/noticias-gaceta/politica/grinan-los-casos-corrupcion-pueden-influir-20120226
I want on
Instead of using a regex you can try this which is clean and simple.
$('a').each(function(){
$(this).text(this.protocol + "//" + (this.hostname || this.pathname));
});
Note: If you want to set it only for set of anchors, then change the selector accordingly but the logic inside remains the same.
Working demo - http://jsfiddle.net/ShankarSangoli/8G7JM/3/