T
T
Trahbumbeiten2014-12-13 20:39:29
Domain name market
Trahbumbeiten, 2014-12-13 20:39:29

How to strip everything from a URL except the domain using REGEXP?

To get name.net
............................................... ........

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Nalomenko, 2014-12-13
@nalomenko

What programming language do you need code for? In PHP, for example, this is done like this:
And here is an example for the front-end in javascript:

function cleanUp(url) {
    var url = $.trim(url);
    if(url.search(/^https?\:\/\//) != -1)
        url = url.match(/^https?\:\/\/([^\/?#]+)(?:[\/?#]|$)/i, "");
    else
        url = url.match(/^([^\/?#]+)(?:[\/?#]|$)/i, "");
    return url[1];
}

alert(cleanUp('  http://www.google.com/about.html'));
alert(cleanUp('  www.google.com/about.html'));

For Yahoo Pipes the solution is here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question