regex - In Sublime Text, how do I find and replace all non-coded web addresses with formatted and linked URLs? -


how find , replace non-coded web addresses formatted , linked urls?

the dummy text in example below can represent paragraphs of varying lengths.

example:

`before:

   dummy text. website.dk/info    dummy text (website.com) dummy text.    dummy text. website.dk    dummy text. www.website.com 

after:

   dummy text. <em><a href="http://website.dk/info" target="blank">website.dk/info</a></em>    dummy text (<em><a href="http://website.com" target="blank">website.com</a></em>) dummy text.    dummy text. <em><a href="http://website.dk" target="blank">website.dk</a></em>    dummy text. <em><a href="http://website.com" target="blank">www.website.com</a></em>`  

assuming have more text aren't links, can use regex this:

((?:www\.)?\w+\.?\w+\/?\w+) 

with replacement string

<em><a href="http://$1" target="blank">$1</a></em> 

working demo

enter image description here


Popular posts from this blog

node.js - How do I prevent MongoDB replica set from querying the primary? -

Apache NiFi ExecuteScript: Groovy script to replace Json values via a mapping file -