Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js convert urls in content to links

function convert(text)
{
  var exp = /((https?|ftp|file)://[-A-Z0-9+&@#/%?=~_|!:,.;]*[-A-Z0-9+&@#/%=~_|])/ig;
  var text1=text.replace(exp, "<a href='$1'>$1</a>");
  var exp2 =/(^|[^/])(www.[S]+(|$))/gim;
  return text1.replace(exp2, '$1<a target="_blank" href="http://$2">$2</a>');
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: node.js version change to 6.14.15 windows 
Javascript :: createTextFinder matchcase example 
Javascript :: next js global layout 
Javascript :: how 2 stop gif loop jsx 
Javascript :: input creates console log delay 
Javascript :: createelement and set prop attr jquery 
Javascript :: too many rerenders 
Javascript :: Refresh page after dialoge closes 
Javascript :: Nested comparison operator in Javascript 
Javascript :: replacing value of arrayObj using map and spread operator 
Javascript :: Grad points by javascript switch 
Javascript :: How to assign set a function as Variable 
Javascript :: use variable in form action vuejs 
Javascript :: How To Upload File To Alicloud OSS with node.js and Express 
Javascript :: how to retrieve get parameters from javascript 
Javascript :: import js with vite ts 
Javascript :: Pausing setInterval when page/ browser is out of focus 
Javascript :: online javascript coding test 
Javascript :: go-gitea/gitea 
Javascript :: toast not at bottom 
Javascript :: javascript centuries 
Javascript :: Logical Assignment Operator null coalescing 
Javascript :: remove port number from url node js 
Javascript :: chrome extension get current tab 
Javascript :: fastest way to sort an array html tags front 
Javascript :: react native paper touchable ripple 
Javascript :: provider._web3Provide.sendAsync as any 
Javascript :: loadash 
Javascript :: why typescript is superset of javascript 
Javascript :: Get physical path in javascript 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =