Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js replace text link with anchor tags

var exp_match = /((https?|)://[-A-Z0-9+&@#/%?=~_|!:,.;]*[-A-Z0-9+&@#/%=~_|])/ig;
   var element_content=content.replace(exp_match, "<a href='$1'>$1</a>");
   var new_exp_match =/(^|[^/])(www.[S]+(|$))/gim;
   var new_content=element_content.replace(new_exp_match, '$1<a target="_blank" href="http://$2">$2</a>');
Comment

PREVIOUS NEXT
Code Example
Javascript :: javaScript setMonth() Method 
Javascript :: loop through async javascript -1 
Javascript :: javascript check type of variable var 
Javascript :: math.ceil 
Javascript :: decrementar en java 
Javascript :: sitecore rendering paramaters get 
Javascript :: final-form reset form 
Javascript :: how to test usehistory in jest 
Javascript :: react linking to documents 
Javascript :: vue js data bind 
Javascript :: ffmpeg thumbnail generator SIZE 
Javascript :: new features of angular 11 
Javascript :: js remove trailling lines 
Javascript :: js double click to edit 
Javascript :: Get Country from the international phone number 
Javascript :: version check 
Javascript :: strapi blank dashboard page 
Javascript :: star looping javascript 
Javascript :: javascript getHours from epoch 
Javascript :: js !! 
Javascript :: Highest Scoring Word 
Javascript :: hook usePreloadImages 
Javascript :: close button react 
Javascript :: ondragover js 
Javascript :: rating calculator formula javascript 
Javascript :: ApolloClient 
Javascript :: how to hide footer in specefic pages in react router 
Javascript :: javascript access pushed element 
Javascript :: Axios GET Req with Basic Auth and Error 
Javascript :: push object into array javascript 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =