Created
January 10, 2019 13:06
-
-
Save vrdriver/7211c5faf8180599c1e68df1c3bf14a4 to your computer and use it in GitHub Desktop.
Strip the href link from a link
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'd added this here too: https://stackoverflow.com/a/54129320/1190051