Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

get url from string javascript

function Purify(text) {
    var urlRegex = /^(https?://)?([da-z.-]+).([a-z.]{2,6})([/w .-]*)*/?$/;
    return text.replace(urlRegex, function (url) {
        return '<a class="text-blurple" target="_blank" href="' + url + '">' + url + '</a>';
    })
}
 
PREVIOUS NEXT
Tagged: #url #string #javascript
ADD COMMENT
Topic
Name
4+2 =