Welcome aboard! We are happy you are here and wish you good net-raft!
// put into script.js
var http = require('http');
var srv = http.createServer(function (req, res) {
var str = "some text https://net-raft.com some text https://net-raft.com/Questions/2421/create-qr-code-nodejs/2421"
var regex = /(http|https):\/\/(\w+:{0,1}\w*)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%!\-\/]))?/;
var text = "";
var word = str.split(' ');
for (var y = 0; y < word.length; y++) {
if(!regex .test(word[y]))
text = text + " " + word[y];
else
text = text + " " + "<" + "a href=" + word[y] + " target=_blank>" + word[y] + "<a>";
}
res.writeHead(200, {'Content-Type': 'text/html'});
res.end(text);
});
srv.listen(3000);
console.log("Listening to Port 3000");
// type into command prompt "node script.js"
// put this url http://localhost:3000/ into any browser
The most helpful NODEJS solutions
get user ipNODEJS Click to see more ... 7.5K 1.7K