Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Convert Strings into Anchor tags using Regex and Javascript
"If you are looking to fix strings that look like urls in text and convert them to ulrs like this http:// you can use Regex in javascript to replace strings with a format of you liking even if a url is at the end of your string like".replace(/((\w+:\/\/\S+)|(\w+[\.:]\w+\S+))[^\s,\.]/mg,'<a href="$&" target="_blank">$&</a>')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment