JSFiddle - React, Tailwind, and code Playground
by kentnl
HTML
<div id="output"></div>
<div id="data">
This is some sample text, with a few embedded urls we want to extract in it.
http://example.com
http://example.com/
http://example.com/super
https://example.com/super
example.com/super
example.com
example.com/su-per_duper/?add=yes&subtract=no
example.com/archive/index.html
twitter.com/#!/reply
example.com/234ret2398oent/234nth
codegolf.stackexchange.com/questions/464
crazy.wow.really.example.com/?cat=nth%3E
example-example.com
example1.com
Not Match:
example
super/cool
Good Morning
i:can
hello.
</div>
CSS
#data {
display: none;
}
JavaScript
$(function($){
var data = $("#data").text();
var re = /(\S+\.[^/\s]+(\/\S+|\/|))/g;
//console.log( data.match(re) );
$.each(data.match(re), function( index, value ){
$("#output").append("<div>" + value + "</div>");
});
});