Skip to content

Instantly share code, notes, and snippets.

@vrdriver
Created January 10, 2019 13:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vrdriver/7211c5faf8180599c1e68df1c3bf14a4 to your computer and use it in GitHub Desktop.
Save vrdriver/7211c5faf8180599c1e68df1c3bf14a4 to your computer and use it in GitHub Desktop.
Strip the href link from a link
This will change a string of text link from (for example):
<a href="http://helloworld.com">Cool link</a>
to
helloworld.com
// Just exports the URL as text - with no link.
striplinks(text)
{
var re = /<a\s.*?href=[\"\'](.*?)[\"\']*?>(.*?)<\/a>/g;
var str = text;
var subst = '$2';
var result = str.replace(re, subst);
return result;
}
@vrdriver
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment